-
Notifications
You must be signed in to change notification settings - Fork 6
Backup & Restore
Essentially, all data resides on two docker volumes: parkour2_pgdb
and parkour2_media
. The rsnapshot
container saves a series of incremental backups into ./rsnapshot/backups/
once you start the app in production mode. If you were to use a different location, we recommend you just create a symbolic link with the aforementioned path as destination and your chosen location as source.
It's up to you manually backing up all the relevant files, plus having proper off-site copies. Aside from the whole Django project (e.g. parkour2/
repo clone), the following files are critical (and not tracked by git!)...
- General config:
./misc/parkour.env
&./misc/nginx-server.conf
- TLS encryption:
./misc/cert.pem
&./misc/key.pem
- Snapshots:
./rsnapshot/backups
, including the following:- Database:
./misc/*.sqldump
these are generated by Makefile rules:save-postgres
(or,convert-backup
), and they're named with a timestamp from the moment you callmake
. There's a symlink./misc/latest.sqldump
pointing to the most recently generated*.sqldump
file. - Uploaded files (e.g.
./rsnapshot/backups/daily.0/localhost/data/parkour2_media/
)
- Database:
Note
Get familiar with rsnapshot's docs. If you wanted to customize the frequency at which these snapshots are taken, and how many of these are kept, check the files under ./misc/rsnapshot/config
; but what we have is of great fading granularity. There's hardly any need to change it.
Important
When restoring a database backup, it is common (and safe!) to ignore these 3 messages:
pg_restore: error: COPY failed for table "auth_permission": ERROR: duplicate ke value violates unique constraint "auth_permission_pkey"
DETAIL: Key (id)=(1) already exists.
CONTEXT: COPY auth_permission, line 1
pg_restore: error: COPY failed for table "django_content_type": ERROR: duplicate ke value violates unique constraint "django_content_type_pkey"
DETAIL: Key (id)=(1) already exists.
CONTEXT: COPY auth_permission, line 1
pg_restore: error: COPY failed for table "django_migrations": ERROR: duplicate ke value violates unique constraint "django_migrations_pkey"
DETAIL: Key (id)=(1) already exists.
CONTEXT: COPY auth_permission, line 1
These happen specifically with the DB tables: auth_permission
, django_content_type
, and django_migrations
. It's important that only these 3 tables are mentioned. After such messages, pg_restore
will report the number of errors that were ignored. If there were more than 3, something else is off. That is to say that any other errors need to be taken care of with special attention (e.g. database schema diverged because of missed migrations), and the Parkour app will run seemingly correct (after all, errors were ignored); but would probably have tables with missing data (e.g. concentration values somewhere).