Backups
Remote backup of user directory and MySQL database that deletes the backup from 4 weeks ago
serverLocation="example.com"; syncLocation="/media/StorageDrive/example.com.sync/"; saveLocation="/media/StorageDrive/example.com.backups/"; rsync -a root@$serverLocation:/home/ $syncLocation/home/; ssh root@$serverLocation -t "mysqldump --all-databases" > $syncLocation/mysql.sql; cd $syncLocation; tar -cvzf $saveLocation/$(date +%y-%m-%d).tar . ; rm -f /home/user123/mail-backup-$(date --date="4 weeks ago" +%y-%m-%d).tar;
Local cron backup command for one email account that deletes backups after two weeks
tar -cvf /home/user123/mail-backup-$(date +%F).tar /home/user123/mail/example.com/info/; rm -f /home/user123/mail-backup-$(date --date="2 weeks ago" +%F).tar; > /dev/null
Backup commands
safe_pkgacct safe_restorepkg mv_backup