mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-23 17:54:22 +00:00
0e344ac8bb
Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/39 Co-authored-by: norm <normandy@biribiri.dev> Co-committed-by: norm <normandy@biribiri.dev>
3.5 KiB
3.5 KiB
Backup/Restore/Move/Remove your instance
Backup
- Stop the Akkoma service.
- Go to the working directory of Akkoma (default is
/opt/akkoma
) - Run
sudo -Hu postgres pg_dump -d <akkoma_db> --format=custom -f </path/to/backup_location/akkoma.pgdump>
(make sure the postgres user has write access to the destination file) - Copy
akkoma.pgdump
,config/prod.secret.exs
,config/setup_db.psql
(if still available) and theuploads
folder to your backup destination. If you have other modifications, copy those changes too. - Restart the Akkoma service.
Restore/Move
- Optionally reinstall Akkoma (either on the same server or on another server if you want to move servers).
- Stop the Akkoma service.
- Go to the working directory of Akkoma (default is
/opt/akkoma
) - Copy the above mentioned files back to their original position.
- Drop the existing database and user if restoring in-place.
sudo -Hu postgres psql -c 'DROP DATABASE <akkoma_db>;';
sudo -Hu postgres psql -c 'DROP USER <akkoma_db>;'
- Restore the database schema and akkoma postgres role the with the original
setup_db.psql
if you have it:sudo -Hu postgres psql -f config/setup_db.psql
.
Alternatively, run the mix pleroma.instance gen
task again. You can ignore most of the questions, but make the database user, name, and password the same as found in your backup of config/prod.secret.exs
. Then run the restoration of the akkoma role and schema with of the generated config/setup_db.psql
as instructed above. You may delete the config/generated_config.exs
file as it is not needed.
- Now restore the Akkoma instance's data into the empty database schema:
sudo -Hu postgres pg_restore -d <akkoma_db> -v -1 </path/to/backup_location/akkoma.pgdump>
- If you installed a newer Akkoma version, you should run
mix ecto.migrate
1. This task performs database migrations, if there were any. - Restart the Akkoma service.
- Run
sudo -Hu postgres vacuumdb --all --analyze-in-stages
. This will quickly generate the statistics so that postgres can properly plan queries. - If setting up on a new server configure Nginx by using the
installation/akkoma.nginx
config sample or reference the Akkoma installation guide for your OS which contains the Nginx configuration instructions.
Remove
- Optionally you can remove the users of your instance. This will trigger delete requests for their accounts and posts. Note that this is 'best effort' and doesn't mean that all traces of your instance will be gone from the fediverse.
- You can do this from the admin-FE where you can select all local users and delete the accounts using the Moderate multiple users dropdown.
- You can also list local users and delete them individualy using the CLI tasks for Managing users.
- Stop the Akkoma service
systemctl stop akkoma
- Disable akkoma from systemd
systemctl disable akkoma
- Remove the files and folders you created during installation (see installation guide). This includes the akkoma, nginx and systemd files and folders.
- Reload nginx now that the configuration is removed
systemctl reload nginx
- Remove the database and database user
sudo -Hu postgres psql -c 'DROP DATABASE <akkoma_db>;';
sudo -Hu postgres psql -c 'DROP USER <akkoma_db>;'
- Remove the system user
userdel akkoma
- Remove the dependencies that you don't need anymore (see installation guide). Make sure you don't remove packages that are still needed for other software that you have running!
-
Prefix with
MIX_ENV=prod
to run it using the production config file. ↩︎