Pleroma Remote Backup

Script to save a Pleroma instance remotely

Optional: Enter the SSH key only once in the current session so that the script does not prompt for every SSH command:

ssh-add

Save the Pleroma configuration. This contains the keys that authenticate the Pleroma instance to the outside world. Also the password for accessing the Postgres database is listed there.

scp server:/etc/pleroma/config.* .

Postgres Database Remote Backup

Once on the Pleroma server make the database accessible without password: vi /root/.pgpass:

localhost:5432:pleroma:pleroma:password

Remotely save the database:

ssh root@server "pg_dump -h localhost -U pleroma pleroma -C" > pleroma.dump

Complete Backup-Script

Here again everything summarized as a script and somewhat refined. The directory for the backups can of course be customized:

#!/bin/bash

server="your_pleroma_server_name_here"

ssh-add
if [ "$?" -ne "0" ]
  then
    echo "aborted"
    exit 255
fi

today=$(date +%Y-%m-%d)
backupdir=~/Backup/Pleroma/$today

mkdir -p $backupdir
cd $backupdir

scp $server:/etc/pleroma/config.* .
ssh root@$server "pg_dump -h localhost -U pleroma pleroma -C" > pleroma.dump

cd ..
zip -r $today.zip $today
rm -rf $today