Backup scripts for Cloud VPSers/VMs with rsync scp git and Snapshots by leveraging cronjobs on OpenBSD
Backup scripts in shell to backup a web directory with rsync, scp, git and snapshots. Tested on OpenBSD 6.6. Read this article for more information.
- Synchronise the web directory to another directory on a VPS over SSH
- Copy the compressed web directory in an encryted AES256 zip file to another VPS over SSH
- Leverage GitHub as a VCS to synchronize the web directory over HTTPS (TLS)
- Snapshot the VPS by an API over HTTPS (TLS)
You find all three scripts in this repository. We configure these script with the help of crontab:
crontab -e
0 3 * * * /home/username/backup-rsync.sh
0 4 * * * /home/username/backup-zip.sh
0 5 * * * /home/username/backup-github.sh
0 6 * * * /home/username/backup-vultr-snapshot.sh
On the target backup VPS we configure a retention time of 180 days with cron. This way, encrypted backups older than 180 days will be automatically purged/deleted to save disk space:
crontab -e
0 7 * * * find /home/username/backup-zip -type f -mtime +180 -name "*.zip.enc" -exec rm {} \;
Berkeley Software Distribution (BSD)
Jeroen van Kessel | cryptsus.com - we craft cyber security solutions