Here is my way to do my backup.
Pull backup over ssh ang git / snapshot it.
- Launch backup remotely
- Pull backup over ssh
- Push .rsc to git
- zfs snapshot receive vol
The date is not in the filename, but in the commit comment, and also in the zfs snapshot name.
#!/bin/sh
. /usr/local/bin/zfs-snapshot
USER_SSH=remote-user
IPs=X.X.X.X
IPa=Y.Y.Y.Y
ZFS=snob/backup/MikroTik
ssh $USER_SSH@$IPs '/export file=flash/Core-backup-swro'
ssh $USER_SSH@$IPs 'system backup save name=flash/Full-bin-swro'
ssh $USER_SSH@$IPa '/export file=Core-backup-acpo'
ssh $USER_SSH@$IPa 'system backup save name=Full-bin-acpo'
scp $USER_SSH@$IPs:/flash/Core-backup-swro.rsc /$ZFS/Router
scp $USER_SSH@$IPs:/flash/Full-bin-swro.backup /$ZFS/Router
scp $USER_SSH@$IPa:/Core-backup-acpo.rsc /$ZFS/AccessPoint
scp $USER_SSH@$IPa:/Full-bin-acpo.backup /$ZFS/AccessPoint
MESSAGE=$(date)
cd /$ZFS/mikrotik-config-git/
git pull
cp /$ZFS/Router/Core-backup-swro.rsc /$ZFS/mikrotik-config-git/
cp /$ZFS/AccessPoint/Core-backup-acpo.rsc /$ZFS/mikrotik-config-git/
git add /$ZFS/mikrotik-config-git/Core-backup-swro.rsc
git add /$ZFS/mikrotik-config-git/Core-backup-acpo.rsc
git commit -m "$(echo $MESSAGE)"
git push
do_snapshots $ZFS 12 hourly
do_snapshots $ZFS 7 daily
do_snapshots $ZFS 4 weekly
do_snapshots $ZFS 6 monthly
]