Skip to main content

Julia Evans

« back to all TILs

Restic for backing up SQLite dbs

One of the missing pieces about databases for me has been what to use for backups. I recently decided to go with restic and it seems to be working okay so far.

My backup script looks somethnig like this. It pings healthchecks.io when it’s done.

sqlite3 /data/requests.sqlite "VACUUM INTO '/tmp/requests.sqlite'"
gzip /tmp/requests.sqlite

restic -r s3://s3.amazonaws.com/MY_BUCKET/ backup /tmp/requests.sqlite.gz 
restic -r s3://s3.amazonaws.com/MY_BUCKET/ forget -l 7 -H 12 -d 2 -w 2 -m 2 -y 2
restic -r s3://s3.amazonaws.com/MY_BUCKET/ prune
curl https://hc-ping.com/ID