#!/usr/bin/env sh echo "Last run: $(date -R)" > /root/backup.last-run for backupTarget in desastro lollo do echo "Backing up to: $backupTarget" >> /root/backup.last-run echo "Status:" >> /root/backup.last-run #backup services for service in synapse do sudo -u $service restic init --password-file /var/lib/$service/restic-password --repo rest:https://restic:$(cat /var/lib/restic-password-$backupTarget)@restic.$backupTarget.ctu.cx/$(hostname)-$service sudo -u $service restic backup --password-file /var/lib/$service/restic-password --repo rest:https://restic:$(cat /var/lib/restic-password-$backupTarget)@restic.$backupTarget.ctu.cx/$(hostname)-$service /var/lib/$service if [ $? -eq 0 ]; then echo "$service: OK" >> /root/backup.last-run else echo "$service: FAIL" >> /root/backup.last-run fi done #backup postgres SQLFILE=/var/lib/postgresql/backup/postgres.sql sudo -u postgres mkdir /var/lib/postgresql/backup sudo -u postgres sh -c "pg_dumpall > $SQLFILE" sudo -u postgres restic init --password-file /var/lib/postgresql/restic-password --repo rest:https://restic:$(cat /var/lib/restic-password-$backupTarget)@restic.$backupTarget.ctu.cx/$(hostname)-postgres sudo -u postgres restic backup --password-file /var/lib/postgresql/restic-password --repo rest:https://restic:$(cat /var/lib/restic-password-$backupTarget)@restic.$backupTarget.ctu.cx/$(hostname)-postgres /var/lib/postgresql/backup if [ $? -eq 0 ]; then echo "postgres: OK" >> /root/backup.last-run else echo "postgres: FAIL" >> /root/backup.last-run fi sudo -u postgres rm -rf /var/lib/postgresql/backup done