External drive and --keep-within

Hi!

I’ve been trying to figure out the difference between --keep and --keep-within. I have an external drive I make irregular backups to. I would like there to ALWAYS be:

12 monthly snapshots
5 yearly snapshots

Which option should I use?

Thanks in advance!

From your description, you should use --keep-monthly 12 --keep-yearly 5.

Please use the --dry-run option to the forget command to test run your policy.

Also note that you might need to tweak the grouping of snapshots with --group-by, depending on what they have as their host, tags and paths.

Thanks. Are there any examples of --keep-within-* usage where it’s more preferable over just --keep? Why was this option added at all? I’d very much like if the manual had more examples regarding the difference between the two.

To allow fine tuning what you want to keep.

There is potentially massive difference between keeping last 30 daily snapshots vs keeping daily snapshots within the last month.

Imagine you run backup once per week. The first option will keep 30 snapshots spanning period of almost 3 years when the latter will keep only last 4.

But when you run backups daily results will be the same.

In your case --keep-monthly 12 vs --keep-within-monthly 1y as long as you always run backups on schedule will yield the same results. But if you skip some monthly backups results will differ.

1 Like

@CodingChipmunk Does this example make sense to you?

BTW - my maths was wrong:) But principle difference stands.

Result of:

30 daily snapshots vs keeping daily snapshots within the last month (30 days)

For weekly backups would be:

30 weeks worth of backups vs keeping only last 4

You are right about using --dry-run for snapshots forgetting setup. Very easy to make mistake and lose some data forever.

Yes, it makes more sense now! Thanks @rawtaz and @kapitainsky