Automagically removing old reverse incremental backups. Using the old --backup-dir flag with dated backup folders, so everytime the backup is run, a new reverse increment is created.
Looking for some battle tested code (pref bash code?) that prunes the backup to say 1 copy max per day, 1 per week, 1 per month and 1 per year. i.e. log span over 1 year.
I'm not looking to be able to do restore state at a point in time precisely, just want to be able to pull old versions of individual files out over a decent span of time if necessary.
Barring that, maybe some hints/constructive challenges with pseudo code? I'm currently thinking of:
- Set up cron to trigger recurring daily, weekly, monthly and yearly
- Use initial call Tref = 4 AM in the morning or sometime where load is non-intrusive
- cron calls the backup script with an arg flag like -D, or -DW, or -DWM (and I supposed -DM and -WM are also possible variants)
- Allow for some smarts in cron and/or code to deal with over lapping calls using lock or something.
e.g. -D and -DW would "always" overlap once every 7 days. -D should be inhibited.
- each time the backup script is called it does its rclone --backup-dir thing. Each backup folder is marked with flag (D, DW, DWM, etc as per arg) to indicate the applicable pool.
- Depending on arg flags, delete rclone older entries on a per pool basis:
* arg contains D flag: its been 1 day since last D call. Delete all folders containing D mark except for the most recent X copies.
* arg contains W flag. its been 1 week since last W call. Delete all folders containing W mark except for the most recent Y copies.
etc. X and Y values are pre-set inside the backup script.
The trick here is dealing with the overlapping calls and obv only deleting the right files because its irreversible. Hence why looking for battle tested code.
Suppose I could test with cron running on fake accelerated frequencies and dummy calls.... but i really would rather start from something (or use something already done) rather than just my pseudo code.
Note: this is very much like timeshift's retain scheme.
- os/version: linuxmint 21.2 (64 bit)
- os/kernel: 5.15.0-91-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.21.5
- go/linking: static
- go/tags: none
most likely b2
Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.