To make a backup copy of the database, simply do a "dump" and redirect the results to a file.

cd /home/sqlite
sqlite3 sample.db .dump > sample.bak

 

Restoring the database from a backup is just as easy as backing up, except we must make sure the destination database is empty first. Alternatively you may want to delete or rename the destination database and let sqlite create a new one for you.

cd /home/sqlite
mv sample.db sample.db.old
sqlite3 sample.db < sample.bak

 

After restoring, verify the results.

sqlite3 sample.db 'select * from music;'
Beastie Boys|Paul's Boutique
John, Elton|Goodbye Yellow Brick Road
Parliment|Mothership Connection