mirror of
https://git.yandere.love/skylar/pleromer-stuff.git
synced 2025-02-05 04:07:27 +00:00
Add backup & restore commands
This commit is contained in:
parent
8e52f971c9
commit
e8639069fb
30
backup.md
Normal file
30
backup.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
This is the script I use for routine backups of a pleroma server where I don't have access to the hypervisor. We need a few things:
|
||||||
|
- The pgsql database dumped to a file
|
||||||
|
- The contents of /opt/pleroma, mostly the uploads directory
|
||||||
|
- And it doesn't hurt to grab all of /etc to make sure we've got the latest nginx config and anything else that could make restoring to a new server easier.
|
||||||
|
|
||||||
|
```
|
||||||
|
#!/bin/bash
|
||||||
|
cd /opt/pleroma
|
||||||
|
echo Backup started at $(date)
|
||||||
|
sudo -Hu postgres pg_dump -d pleroma --format=custom -f /var/tmp/pleroma.pgsql
|
||||||
|
rsync -e "ssh -i $HOME/.ssh/backup_rsa -p 22" -avzh /opt/pleroma /etc /var/tmp/pleroma.pgsql pleroma-backup@server.example.com:/data
|
||||||
|
rm -f /var/tmp/pleroma.pgsql
|
||||||
|
```
|
||||||
|
|
||||||
|
For restoring the database and files, the easiest way I've found to do so is installing a fresh copy of pleroma of the same or later version and then restoring the backed up copy over top of it.
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo -Hu pleroma git clone -b develop https://git.pleroma.social/pleroma/pleroma /opt/pleroma
|
||||||
|
sudo -Hu pleroma mix deps.get
|
||||||
|
sudo -Hu pleroma MIX_ENV=prod mix pleroma.instance gen
|
||||||
|
sudo -Hu postgres psql -c 'DROP DATABASE pleroma;';
|
||||||
|
sudo -Hu postgres psql -c 'DROP USER pleroma;'
|
||||||
|
sudo -Hu postgres psql -f config/setup_db.psql
|
||||||
|
sudo -Hu postgres pg_restore -d pleroma -v /opt/pleroma/backup.pgsql -j 5
|
||||||
|
sudo -Hu pleroma MIX_ENV=prod mix ecto.migrate
|
||||||
|
sudo -Hu postgres vacuumdb --all --analyze-in-stages
|
||||||
|
sudo -Hu pleroma MIX_ENV=prod mix pleroma.frontend install pleroma-fe
|
||||||
|
systemctl start pleroma
|
||||||
|
```
|
||||||
|
After that, the uploads directory, custom emoji, and theme will need to go back in place, but it should be 99% working.
|
Loading…
x
Reference in New Issue
Block a user