Aktionen
SQLite¶
Backup DB¶
While SQLite-DB consists of just one file, you shouldn't just copy the file. It might be corrupted by doing so.
If you want to copy the DB-file you might want to (taken from http://stuvel.eu/blog/55/safely-copy-a-sqlite-database)
shell$ sqlite3 some.db
sqlite> begin immediate;
<press CTRL+Z>
shell$ cp some.db some.db.backup
shell$ exit
sqlite> rollback;
the other way may be dumping the DB. This is easily done by
sqlite3 sample.db .dump > sample.bak
based on the rsnapshot-backup-script for postgresql following script might be invoked by rsnapshot
############################################################################## # backup_sqlite.sh # # by Jeremias Keihsler <j@keihsler.com> # http://www.keihsler.com/ # # based on the backup_pgsql.sh script # by Nathan Rosenquist <nathan@rsnapshot.org> # # This is a simple shell script to backup a SQLite database with rsnapshot. # # The assumption is that this will be invoked from rsnapshot and also that it # will run unattended. # # This script simply needs to dump a file into the current working directory. # rsnapshot handles everything else. ############################################################################## umask 0077 # backup the database /usr/bin/sqlite3 /var/www/html/owncloud/data/owncloud.db .dump > owncloud_dumpall.sql # make the backup readable only by root /bin/chmod 600 owncloud_dumpall.sql
Restore DB¶
mv sample.db sample.db.old
sqlite3 sample.db < sample.bak
Von Jeremias Keihsler vor fast 8 Jahren aktualisiert · 2 Revisionen