Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take backups via sqlite ".backup" #2214

Merged
merged 1 commit into from
Dec 11, 2024
Merged

Conversation

mikerkelly
Copy link
Contributor

@mikerkelly mikerkelly commented Dec 9, 2024

Partially fixes #2151. ADR about the core backup strategy will be in a separate PR.

Taking backups via the sqlite CLI is simple and clean. We can restore from them.

We haven't been able to locally restore from the dumpdata fixtures-based backups. For now, keep the old-format backups just in case we want to try again to restore from them. After 30 days of creating new backups we can update the script to not consider the old format and location.

See these comments about the execution time and file system space requirements.

Taking backups via the sqlite CLI is simple and clean. We can restore from
them.

We haven't been able to locally restore from the `dumpdata` fixtures-based
backups. For now, keep the old-format backups just in case we want to try to
restore again to from them. After 30 days of creating new backups we can update
the script to not consider the old format and location.

Start taking backups in `/storage/backup` rather than directly in `/storage` to
aid navigation and management of backups.

Set -x in `backup.sh` to print the commands used as this aids remote debugging.
Copy link
Contributor

@Jongmassey Jongmassey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, have you considered using zstd instead of gz here? It's installed on dokku3 and is significantly faster for the same file sizes

time gzip -f db.sqlite3

real    2m36.764s
user    2m30.439s
sys     0m3.521s

1.1G Dec 11 12:52 db.sqlite3.gz

time zstd db.sqlite3 -o db.sqlite3.zstd
real    0m29.130s
user    0m24.160s
sys     0m10.851s

1.1G Dec 11 12:52 db.sqlite3.zstd

@mikerkelly mikerkelly merged commit 84bd078 into main Dec 11, 2024
6 checks passed
@mikerkelly mikerkelly deleted the mikerkelly/backups-via-sqlite-cli branch December 11, 2024 17:26
@mikerkelly
Copy link
Contributor Author

mikerkelly commented Dec 16, 2024

#2248 for zstd compression.

mikerkelly added a commit that referenced this pull request Feb 5, 2025
These lines were gradually removing old-format backups as they aged out past 30
days. Now there are none left, they do no useful work and are no longer
required.

We changed the format of backups from `.json` to `.sqlite3` in #2214
(cdbacb6)  on Dec 9, 2024.

We changed the compression format from `gzip` to `Zstandard` in #2248
(7984176) on Dec 16, 2024.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use sqlite cli to backup core database
2 participants