fix(docs): update Docker steps in backup guide

Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2549>
This commit is contained in:
Ciarán Ainsworth 2023-11-16 11:27:48 +00:00 committed by Marge
parent 048b20130f
commit b11b0dfd52
1 changed files with 43 additions and 30 deletions

View File

@ -9,8 +9,8 @@ Before performing big changes, we recommend you back up your database and media
:::{tab-item} Debian :::{tab-item} Debian
:sync: debian :sync: debian
```{code-block} sh ```console
sudo -u postgres -H pg_dumpall -c 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
``` ```
::: :::
@ -18,8 +18,16 @@ Before performing big changes, we recommend you back up your database and media
:::{tab-item} Docker :::{tab-item} Docker
:sync: docker :sync: docker
```{code-block} sh 1. Stop the running containers:
sudo docker compose exec postgres pg_dumpall -c -U postgres > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
```console
$ sudo docker compose down
```
2. Dump the database to a backup file:
```console
$ sudo docker compose run --rm postgres pg_dump -U postgres postgres > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
``` ```
::: :::
@ -32,9 +40,9 @@ Before performing big changes, we recommend you back up your database and media
:::{tab-item} Debian :::{tab-item} Debian
:sync: debian :sync: debian
```{code-block} sh ```console
rsync -avzhP /srv/funkwhale/data/media /path/to/your/backup/media $ rsync -avzhP /srv/funkwhale/data/media /path/to/your/backup/media
rsync -avzhP /srv/funkwhale/data/music /path/to/your/backup/music $ rsync -avzhP /srv/funkwhale/data/music /path/to/your/backup/music
``` ```
::: :::
@ -42,10 +50,9 @@ Before performing big changes, we recommend you back up your database and media
:::{tab-item} Docker :::{tab-item} Docker
:sync: docker :sync: docker
```{code-block} sh ```console
$ rsync -avzhP /srv/funkwhale/data/media /path/to/your/backup/media
rsync -avzhP /srv/funkwhale/data/media /path/to/your/backup/media $ rsync -avzhP /srv/funkwhale/data/music /path/to/your/backup/music
rsync -avzhP /srv/funkwhale/data/music /path/to/your/backup/music
``` ```
::: :::
@ -58,8 +65,8 @@ Before performing big changes, we recommend you back up your database and media
:::{tab-item} Debian :::{tab-item} Debian
:sync: debian :sync: debian
```{code-block} sh ```console
rsync -avzhP /srv/funkwhale/config/.env /path/to/your/backup/.env $ rsync -avzhP /srv/funkwhale/config/.env /path/to/your/backup/.env
``` ```
::: :::
@ -67,8 +74,8 @@ Before performing big changes, we recommend you back up your database and media
:::{tab-item} Docker :::{tab-item} Docker
:sync: docker :sync: docker
```{code-block} sh ```console
rsync -avzhP /srv/funkwhale/.env /path/to/your/backup/.env $ rsync -avzhP /srv/funkwhale/.env /path/to/your/backup/.env
``` ```
::: :::
@ -84,16 +91,16 @@ To restart your files, do the following:
1. Rename your current file directories. 1. Rename your current file directories.
```{code-block} sh ```console
mv /srv/funkwhale/data/media /srv/funkwhale/data/media.bak $ mv /srv/funkwhale/data/media /srv/funkwhale/data/media.bak
mv /srv/funkwhale/data/music /srv/funkwhale/data/music.bak $ mv /srv/funkwhale/data/music /srv/funkwhale/data/music.bak
``` ```
2. Restore your backed-up files to the original directories. 2. Restore your backed-up files to the original directories.
```{code-block} sh ```console
mv /patht/to/your/backup/media /srv/funkwhale/data/media $ mv /path/to/your/backup/media /srv/funkwhale/data/media
mv /path/to/your/backup/music /srv/funkwhale/data/music $ mv /path/to/your/backup/music /srv/funkwhale/data/music
``` ```
### Restore the database ### Restore the database
@ -107,15 +114,15 @@ To restore your database, do the following:
1. Restore your database backup: 1. Restore your database backup:
```{code-block} sh ```console
sudo -u postgres psql -f /path/to/your/backup/dump.sql funkwhale $ sudo -u postgres psql -f /path/to/your/backup/dump.sql funkwhale
``` ```
2. Run the `funkwhale-manage migrate` command to set up the database. 2. Run the `funkwhale-manage migrate` command to set up the database.
```{code-block} sh ```console
cd /srv/funkwhale $ cd /srv/funkwhale
venv/bin/funkwhale-manage migrate $ venv/bin/funkwhale-manage migrate
``` ```
::: :::
@ -125,14 +132,20 @@ To restore your database, do the following:
1. Restore your database backup. 1. Restore your database backup.
```{code-block} sh ```console
sudo docker compose run --rm -T postgres psql -U postgres postgres < "/path/to/your/backup/dump.sql" $ sudo docker compose run --rm -T postgres psql -U postgres postgres < "/path/to/your/backup/dump.sql"
``` ```
2. Run the `funkwhale-manage migrate` command to set up the database. 2. Run the `funkwhale-manage migrate` command to set up the database.
```{code-block} sh ```console
sudo docker compose run --rm api funkwhale-manage migrate $ sudo docker compose run --rm api funkwhale-manage migrate
```
3. Restart the services.
```console
$ sudo docker compose up -d
``` ```
::: :::