2022-07-01 09:02:29 +00:00
# Back up your Funkwhale instance
Before performing big changes, we recommend you back up your database and media files. Follow the instructions in this guide to back up your instance.
1. Back up your database.
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2023-11-16 11:27:48 +00:00
```console
$ sudo -u postgres -H pg_dumpall -c funkwhale > /path/to/your/backup/dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
2022-07-01 09:02:29 +00:00
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2023-11-16 11:27:48 +00:00
1. Stop the running containers:
```console
2024-10-21 08:57:15 +00:00
$ docker compose down
2023-11-16 11:27:48 +00:00
```
2. Dump the database to a backup file:
```console
2024-10-21 08:57:15 +00:00
$ docker compose run --rm postgres pg_dump -U postgres postgres > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
2022-07-01 09:02:29 +00:00
```
2022-07-23 13:32:35 +00:00
:::
::::
2022-07-01 09:02:29 +00:00
2. Back up your media files. In this example we use [rsync ](https://rsync.samba.org ) to back up the files.
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2023-11-16 11:27:48 +00:00
```console
$ rsync -avzhP /srv/funkwhale/data/media /path/to/your/backup/media
$ rsync -avzhP /srv/funkwhale/data/music /path/to/your/backup/music
2022-07-01 09:02:29 +00:00
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2023-11-16 11:27:48 +00:00
```console
$ rsync -avzhP /srv/funkwhale/data/media /path/to/your/backup/media
$ rsync -avzhP /srv/funkwhale/data/music /path/to/your/backup/music
2022-07-01 09:02:29 +00:00
```
2022-07-23 13:32:35 +00:00
:::
::::
2022-07-01 09:02:29 +00:00
3. Back up your configuration files.
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2023-11-16 11:27:48 +00:00
```console
$ rsync -avzhP /srv/funkwhale/config/.env /path/to/your/backup/.env
2022-07-01 09:02:29 +00:00
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2023-11-16 11:27:48 +00:00
```console
$ rsync -avzhP /srv/funkwhale/.env /path/to/your/backup/.env
2022-07-01 09:02:29 +00:00
```
2022-07-23 13:32:35 +00:00
:::
::::
2022-07-01 09:02:29 +00:00
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.
2022-07-27 20:26:03 +00:00
## Restore a backup
### Restore your files
To restart your files, do the following:
1. Rename your current file directories.
2023-11-16 11:27:48 +00:00
```console
$ mv /srv/funkwhale/data/media /srv/funkwhale/data/media.bak
$ mv /srv/funkwhale/data/music /srv/funkwhale/data/music.bak
2022-07-27 20:26:03 +00:00
```
2. Restore your backed-up files to the original directories.
2023-11-16 11:27:48 +00:00
```console
$ mv /path/to/your/backup/media /srv/funkwhale/data/media
$ mv /path/to/your/backup/music /srv/funkwhale/data/music
2022-07-27 20:26:03 +00:00
```
### Restore the database
To restore your database, do the following:
::::{tab-set}
:::{tab-item} Debian
:sync: debian
1. Restore your database backup:
2023-11-16 11:27:48 +00:00
```console
$ sudo -u postgres psql -f /path/to/your/backup/dump.sql funkwhale
2022-07-27 20:26:03 +00:00
```
2023-01-13 15:33:23 +00:00
2. Run the `funkwhale-manage migrate` command to set up the database.
2022-07-27 20:26:03 +00:00
2023-11-16 11:27:48 +00:00
```console
$ cd /srv/funkwhale
$ venv/bin/funkwhale-manage migrate
2022-07-27 20:26:03 +00:00
```
:::
:::{tab-item} Docker
:sync: docker
1. Restore your database backup.
2023-11-16 11:27:48 +00:00
```console
2024-10-21 08:57:15 +00:00
$ docker compose run --rm -T postgres psql -U postgres postgres < "/path/to/your/backup/dump.sql"
2022-07-27 20:26:03 +00:00
```
2023-01-13 15:33:23 +00:00
2. Run the `funkwhale-manage migrate` command to set up the database.
2022-07-27 20:26:03 +00:00
2023-11-16 11:27:48 +00:00
```console
2024-10-21 08:57:15 +00:00
$ docker compose run --rm api funkwhale-manage migrate
2023-11-16 11:27:48 +00:00
```
3. Restart the services.
```console
2024-10-21 08:57:15 +00:00
$ docker compose up -d
2022-07-27 20:26:03 +00:00
```
:::
::::