I am working on systemd service/timer that does this:
backup.service
- done
- restic does the backup
- rclone syncs the restic backup offsite
- restic diffs the last two snapshots files, awk filters the files deleted from the snapshot which are then appended to a file. Command:
ExecStart=/bin/bash -c 'exec /usr/bin/restic diff $$(exec /usr/bin/restic snapshots --json | exec /usr/bin/jq -r \'.[-2:][].id\') | exec /usr/bin/awk \'/^-/{for (i=2; i<NF; i++) printf $$i " "; print $$NF}\' >> $$RESTIC_DELETED_LOG'
(stole part of this command from Script "restic diff" between the last two snapshots).
Updated the awk
command to stop at the first separator (space character) in order to print the whole file, even if the file includes multiple spaces in its name.
backup-deleted-files-notify.service
- wip
- more manipulation will happen here as I need to filter the important directories
- the consolidate, filtered list of deleted files will be emailed out daily at 20 o’clock
prune-check.service
- done
- run weekly
- apply forget policy and prune backup
- check the backup after pruning
Some References: