Tsurugi tgctlによるバックアップ/リストア

 

参考文献: 次世代高速オープンソースRDB Tsurugi (神林飛志 et al. 著)

 


-- 1. データ確認
tgsql --connection tcp://localhost:12345

select count(*) from history;
select count(*) from contracts;

\exit

-- 2. バックアップ

sudo mkdir ${TSURUGI_HOME}/backup
sudo chmod 777 ${TSURUGI_HOME}/backup

tgctl backup create ${TSURUGI_HOME}/backup


ls -l ${TSURUGI_HOME}/backup
du -sh ${TSURUGI_HOME}/backup

 

-- 3. DB初期化

cd $TSURUGI_HOME

./bin/tgctl shutdown

rm -rf var/data/log/

./bin/tgctl start

 

-- 4. データ確認

tgsql --connection tcp://localhost:12345

select count(*) from history;
select count(*) from contracts;

\exit


-- 5. リストア

tgctl restore backup ${TSURUGI_HOME}/backup --force


-- 6. データ確認

tgctl start

tgsql --connection tcp://localhost:12345

select count(*) from history;
select count(*) from contracts;

\exit