Skip to content

Instantly share code, notes, and snippets.

@garenyondem
Created May 15, 2022 15:09
Show Gist options
  • Save garenyondem/8679cdfcca026c01a3a6f600cbc9b329 to your computer and use it in GitHub Desktop.
Save garenyondem/8679cdfcca026c01a3a6f600cbc9b329 to your computer and use it in GitHub Desktop.
Cron-based sqlite backup
#!/bin/bash -x
# Ensure script stops when commands fail.
set -e
# Backup & compress our database to the temp directory.
sqlite3 /path/to/db '.backup /tmp/db'
gzip /tmp/db
# Upload backup to S3 using a rolling daily naming scheme.
aws s3 cp /tmp/db.gz s3://mybucket/db-`date +%d`.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment