5 분 간격으로 실행되는 cronjob에서 sqlite 데이터베이스를 백업하려고합니다. 데이터베이스는 "라이브"이므로 백업을 수행 할 때 실행중인 쿼리가 있습니다.SQLite 백업 전략
제가 백업에 의존 할 수 있도록 데이터베이스를 백업 할 때 올바른 모양인지 확인하고 싶습니다. (의사의)
나의 현재 전략 : 이제
function backup()
{
#try to acquire the lock for 2 seconds, then check the database integrity
sqlite3 mydb.sqlite '.timeout 2000' 'PRAGMA integrity_check;'
if (integrity is ok and database was not locked)
{
#perform the backup to backup.sqlite
sqlite3 mydb.sqlite '.timeout 2000' '.backup backup.sqlite'
if (backup could be performed)
{
#Check the consistency of the backup database
sqlite3 backup.sqlite 'PRAGMA integrity_check;'
if (ok)
{
return true;
}
}
}
return false;
}
, 내 전략과 몇 가지 문제가 있습니다 : 라이브 데이터베이스가 잠겨있는 경우
이- , 나는이 문제에 실행 내가 때문에 그러면 백업을 수행 할 수 없습니다. 어쩌면 거래가 도움이 될 수 있을까요?
PRAGMA integrity_check;
과 백업간에 문제가 발생하면 나는 해결할 수 없습니다.
아이디어가 있으십니까? 그리고 그런데 과 좋은 오래된 cp mydb.sqlite mybackup.sqlite
의 차이점은 무엇입니까?
[편집] 사람이 어떤 루비 래퍼로 sqlite online backup api 제안 그래서 만약 내가, 임베디드 시스템에 nodejs를 실행 해요 - 아니 기회를 (