From c798fc4ea1c5475ae1cd3d492eaff3a7a8c38344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciar=C3=A1n=20Ainsworth?= Date: Wed, 27 Jul 2022 20:26:03 +0000 Subject: [PATCH] Resolve "Add restore documention in backup section" --- changes/changelog.d/1627.doc | 1 + .../upgrade_docs/backup.md | 64 ++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 changes/changelog.d/1627.doc diff --git a/changes/changelog.d/1627.doc b/changes/changelog.d/1627.doc new file mode 100644 index 000000000..49bd506bf --- /dev/null +++ b/changes/changelog.d/1627.doc @@ -0,0 +1 @@ +Add restore instructions to backup docs (#1627). diff --git a/docs/administrator_documentation/upgrade_docs/backup.md b/docs/administrator_documentation/upgrade_docs/backup.md index 1e5a82c62..6d9500732 100644 --- a/docs/administrator_documentation/upgrade_docs/backup.md +++ b/docs/administrator_documentation/upgrade_docs/backup.md @@ -10,7 +10,7 @@ Before performing big changes, we recommend you back up your database and media :sync: debian ```{code} bash - sudo -u postgres -H pg_dump funkwhale > /path/to/your/backup/dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql + sudo -u postgres -H pg_dumpall -c funkwhale > /path/to/your/backup/dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql ``` ::: @@ -75,3 +75,65 @@ Before performing big changes, we recommend you back up your database and media :::: If you are performing regular backups, you may need deduplication and compression to keep the size down. In this case, a tool like [`borg`](https://www.borgbackup.org/) is more appropriate. + +## Restore a backup + +### Restore your files + +To restart your files, do the following: + +1. Rename your current file directories. + + ```{code} bash + mv /srv/funkwhale/data/media /srv/funkwhale/data/media.bak + mv /srv/funkwhale/data/music /srv/funkwhale/data/music.bak + ``` + +2. Restore your backed-up files to the original directories. + + ```{code} bash + mv /patht/to/your/backup/media /srv/funkwhale/data/media + mv /path/to/your/backup/music /srv/funkwhale/data/music + ``` + +### Restore the database + +To restore your database, do the following: + +::::{tab-set} + +:::{tab-item} Debian +:sync: debian + +1. Restore your database backup: + + ```{code} bash + sudo -u postgres psql -f /path/to/your/backup/dump.sql funkwhale + ``` + +2. Run the `manage.py migrate` command to set up the database. + + ```{code} bash + cd /srv/funkwhale/api + poetry run python manage.py migrate + ``` + +::: + +:::{tab-item} Docker +:sync: docker + +1. Restore your database backup. + + ```{code} bash + docker-compose run --rm -T postgres psql -U postgres postgres < "/path/to/your/backup/dump.sql" + ``` + +2. Run the `manage.py migrate` command to set up the database. + + ```{code} bash + docker-compose run --rm api python manage.py migrate + ``` + +::: +::::