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

Fix location of DB to take backup from #2242

Merged
merged 3 commits into from
Dec 13, 2024

Conversation

mikerkelly
Copy link
Contributor

@mikerkelly mikerkelly commented Dec 13, 2024

Fixes #2214, which was broken. Partially fixes #2151.

Within the container, /app/db.sqlite3 is an apparently empty DB, /storage/db.sqlite3 is the actual app DB of several GB. I'm not sure why the former exists. But this script was backing that up, not the intended DB.

For example, when this ran in production as scheduled the first time the produced backup file is only a few tens of bytes in size.

mikerkelly@dokku3:~$ ls /var/lib/dokku/data/storage/opencodelists/backup/db/ -lrth
total 4.0K
-rw-r--r-- 1 opencodelists opencodelists 114 Dec 12 01:00 2024-12-12-db.sqlite3.gz

Within the container, /app/db.sqlite3 is an apparently empty DB, /storage/db.sqlite3 is the actual app DB of several GB.
I'm not sure why the former exists. But this script was backing that up, not the intended DB.

For example, when this ran in production as scheduled the first time the
produced backup file is only a few tens of bytes in size.

```
mikerkelly@dokku3:~$ ls /var/lib/dokku/data/storage/opencodelists/backup/db/ -lrth
total 4.0K
-rw-r--r-- 1 opencodelists opencodelists 114 Dec 12 01:00 2024-12-12-db.sqlite3.gz
```
Make the target a relative path -- an absolute one won't mean the same thing in
the host file system if executed inside a container as we expect.

For example, when this ran in production as scheduled the first time I realized
the symlink refers to /storage/ which doesn't work in the host file system --
and therefore can't be used over SCP for example:

```
mikerkelly@dokku3:~$ ls /var/lib/dokku/data/storage/opencodelists/backup/db/ -lrth
total 4.0K
-rw-r--r-- 1 opencodelists opencodelists 114 Dec 12 01:00 2024-12-12-db.sqlite3.gz
lrwxrwxrwx 1 opencodelists opencodelists  43 Dec 12 01:00 latest-db.sqlite3.gz -> /storage/backup/db/2024-12-12-db.sqlite3.gz
```

Be slightly more precise about what's a file "name" vs file "path".
@mikerkelly mikerkelly changed the title Correct path for DB backup. Fix location of DB to take backup from Dec 13, 2024
@mikerkelly mikerkelly enabled auto-merge December 13, 2024 09:59
The path for the core and coding system databases
is set by the DATABASE_DIR environment variable,
which is managed via the dokku config described
in DEPLOY.md.

By using that env var in this backup script,
we ensure that if the configuration of this
variable changes then this script will continue
to work.
@mikerkelly mikerkelly merged commit 0cc63a6 into main Dec 13, 2024
6 checks passed
@mikerkelly mikerkelly deleted the mikerkelly/backup-db-correct-path branch December 13, 2024 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use sqlite cli to backup core database
2 participants