Oh yeah, restic is awesome
_backup_prepare () {
export $(sudo cat <protected_credentials_file> | xargs)
}
_backup_remove_old_snapshots () {
restic forget -r <repo_name> --keep-weekly 10
}
_backup_verify () {
restic check -r <repo_name>
}
backup () {
echo "---------------Scheduled backup time---------------"
echo ""
_backup_prepare
restic -r <repo_name> --verbose --exclude="$HOME/snap" --exclude="$HOME/Android" --exclude="$HOME/.android" --exclude="$HOME/ApkProjects" backup ~/
echo ""
echo "---------------Backup done, removing old snapshots---------------"
echo ""
_backup_remove_old_snapshots
echo ""
echo "---------------Old snapshots removed, verifying the data is restorable---------------"
echo ""
_backup_verify
echo ""
echo "---------------Backup done and verified!---------------"
}
Then in cron I just have this entry:
20 \* \* \* DISPLAY=:0 kitty -- /bin/zsh --login -c 'source ~/.zshrc; backup; read'
So every time my PC is on @ 20:00, a shell window will pop-up, asking me for password and runs the backup :). Since they are incremental, it takes maybe 10-15 minutes top.