If you don't want to deal with making your own script I highly recommend Backrest, it handles everything you listed for you using Restic.
this post was submitted on 16 May 2025
8 points (90.0% liked)
Linux
7592 readers
545 users here now
A community for everything relating to the GNU/Linux operating system
Also check out:
Original icon base courtesy of lewing@isc.tamu.edu and The GIMP
founded 2 years ago
MODERATORS
I was going to give some suggestions, but it's easiest to say it like this:
if ( ! test -d ~/Backups ) ; then exit; fi
cd ~/Backups
count=`ls -d Main-* | wc -l`
if [ count -gt 11] ; then
rm -rf `ls -rtd Main-* | head -$((count - 11))`
fi
rsync -aL ~/Main Main-`date -Ihours`
You'd run something like that every six hours. Don't expect it to work, but maybe it could help get you started.
By the way, don't forget to make a good backup before you start messing with backup scripts. Also, if the reason you're keeping twelve different backups is to see how things changed over time, put it in git instead.