Backup & Restore¶
A well-maintained Fietsboek instance should have regular backups configured in case data is lost due unforseen reasons.
Note
As a rule of thumb: A backup that you haven’t restored is not a backup!
Part of the backup process is to ensure that the backups actually contain the necessary data and that the restoration process works. Make sure to test your backups on a separate installation of Fietsboek.
Backup¶
The Fietsboek data lives in two places: Most of it is saved in the database, while track images and other “big files” are saved in the data directory.
You should refer to the manual of your DBMS to see what the procedure for a backup is. Using the preferred way for your DBMS ensures that your backup represents a consistent state of the database.
After backing up the database, you should back up the data directory with a
tool of your choice, for example by using tar, rsync or a proper backup
tool like borg:
tar -czf backup.tar.gz path/to/data/dir
In addition to the actual data, you should also note down the Fietsboek version and the database schema version, as backups can only be restored to the same version!
To view the fietsboek version in case you are using git, you can use the
following command:
git rev-parse HEAD
To view the database schema version, use alembic:
.venv/bin/alembic -c development.ini current
Note those value in addition to your backup.
Restore¶
The restoration process works in four steps:
First, we ensure that we are on the correct Fietsboek version. If you are using
git, this can be done with git checkout:
git checkout NOTED_GIT_VERSION_HERE
Then, we get the database schema to the right version:
.venv/bin/alembic -c production.ini upgrade NOTED_ALEMBIC_VERSION_HERE
Now, we can restore the data in the database. This step is dependent on the DBMS that you, therefore you should consult its documentation.
Finally, we can restore the data directory. This step depends on how you chose
to back up the data directory earlier. In the case of tar, you can simply
extract the archive to the right location.