#!/bin/bash mkdir -p /tmp/backups/$(date +"%Y%m%d") # Backup postgres folder tar -zcvf /tmp/backups/$(date +"%Y%m%d")/postgres14.tar.gz /opt/mastodon/postgres14 # Backup public folder tar --exclude=/opt/mastodon/public/system/cache -zcvf /root/backups/$(date +"%Y%m%d")/public.tar.gz /opt/mastodon/public rsync -e 'ssh -p 23' --recursive /root/backups/* u302558-sub3@u302558-sub3.your-storagebox.de: rm -r /root/backups if [ $(ssh -p 23 u302558-sub3@u302558.your-storagebox.de ls | wc -l) -gt "5" ] then echo "More than 3 Backups, delete $(ssh -p 23 u302558-sub3@u302558.your-storagebox.de ls -t | tail -n 5 | tr '\n' ' ')" ssh -p 23 u302558-sub3@u302558.your-storagebox.de rm -r $(ssh -p 23 u302558-sub3@u302558.your-storagebox.de ls | sort | head -n 1) fi # rm -r ~/backups/$(ls ~/backups/ | sort | head -n 1) # tar --exclude=/opt/mastodon/public/system/cache -zcvf ~/$(date +"%Y%m%d")/public.tar.gz /opt/mastodon/public