Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve oldest snapshot when forget policies not satisfied #1032

Closed
kapitainsky opened this issue Feb 1, 2024 · 9 comments
Closed

Preserve oldest snapshot when forget policies not satisfied #1032

kapitainsky opened this issue Feb 1, 2024 · 9 comments

Comments

@kapitainsky
Copy link
Contributor

I would like to suggest restic implemented logic to try to keep the oldest snapshot

restic/restic#4366

At the moment with rustic with for example forget policies:

[forget]
keep-last = 2
keep-daily = 2
keep-weekly = 2
keep-monthly = 2

$ rustic forget
using config ./rustic.toml
[INFO] repository rclone:OD01-ENC:restic-test: password is correct.
[INFO] using cache at /Users/kptsky/Library/Caches/rustic/xxxx
snapshots for (host [kp-laptop.local], label [], paths [/])

ID Time Host Label Tags Paths Action Reason
005a026e 2024-02-01 18:32:35 kp-laptop.local test_rustic / keep last
daily
weekly
monthly
f2c0df87 2024-01-31 15:09:11 kp-laptop.local test_rustic / keep last
daily
monthly
2690ada9 2024-01-31 04:41:52 kp-laptop.local test_rustic / remove
6fa4307a 2024-01-30 08:05:13 kp-laptop.local test_rustic / remove
1dcc6ab7 2024-01-28 09:12:15 kp-laptop.local test_rustic / keep weekly
2bc5f01c 2023-12-31 20:44:27 kp-laptop.local test_rustic / remove

on the 1st of Feb 2024 the last snapshot from 31st of Dec is removed - it is only 31 days old....

I think it is something from restic that can be copied into rustic - much more logical IMO.

@github-actions github-actions bot added the S-triage Status: Waiting for a maintainer to triage this issue/PR label Feb 1, 2024
@aawsome
Copy link
Member

aawsome commented Feb 1, 2024

@kapitainsky What do you expect as outcome here? I think restic does exactly the same here - there are 2 last, 2 daily, 2 weekly and 2 monthly snapshots kept...

@kapitainsky
Copy link
Contributor Author

The latest restic would not remove the latest snapshot - see restic PR I linked

@aawsome
Copy link
Member

aawsome commented Feb 1, 2024

That logic you have linked is already implemented in rustic (it was implemented in rustic before it was added to restic). And in this example it doesn't apply, as all keep-* values are satisfied.

@kapitainsky
Copy link
Contributor Author

kapitainsky commented Feb 1, 2024

And let's be pragmatic and logical - I want to keep last 2 monthly snapshots. In human terms it means I do not expect 1 month old snapshot to be removed (given it is the last one).

This is where pure algorithm logic does not work in real life.

IMO it is very practical to not touch the oldest snapshot - this is what restic does nowadays.

Look at my example - I want to keep 2 months snaps - suddenly I have only last few days. And before running forget I had 1 month.

@aawsome
Copy link
Member

aawsome commented Feb 1, 2024

@kapitainsky Did you read my last comment?

I do think that rustic behaves exactly like restic here and that restic also would remove that last snapshot. Simply because it keeps 2 monthly snapshots, as requested: The one from 2024-02-01 and the one from 2024-01-31.

Can you explain why you expect rustic to keep the snapshot from 2023-12-31 which would be the third monthly snapshot?

@kapitainsky
Copy link
Contributor Author

Because between 2024-02-01 and 2024-01-31 there is 1 day difference? And you are dropping one from 2023-12-31? Which maybe satisfy some artificial logic of 2 months but defies any common sense.

Let's say I started my rustic backup on 31/DEC/2023 - Hurra! my data is safe now. And I set forget policies to keep last 2 months. So now I know that I can restore my files back up to 2 month. All was fine until 1/FEB/2024 when suddenly computer decided you now have only last two days of backups:) WOW. Because my 31/DEC/2023 backup (despite to be less than 2 months old) has been removed.

Very simple adjustment to prevent it is (like restic) to not to remove the oldest snapshot if it does satisfy set policies. It creates sort of exception to algorithmic removal process but makes it much more human friendly.

@aawsome
Copy link
Member

aawsome commented Feb 1, 2024

If you want to keep monthly snapshots which are less then 2 month old, the keep-within-monthly option would be the right choice. Or, you tell rustic to keep 3 monthly snaphots knowing that in the beginning of a month the monthly snapshot is an early one.

Very simple adjustment to prevent it is (like restic) to not to remove the oldest snapshot if it does satisfy set policies. It creates sort of exception to algorithmic removal process but makes it much more human friendly.

Please run restic forget --dry-runfor your example. It will produce exactly the same result as rustic.

@aawsome
Copy link
Member

aawsome commented Feb 1, 2024

I agree that this keep-monthly option may be irritating when you first start. But I decided to act exactly like restic here in order to not confuse people who run restic and rustic on the same repositories. The only thing I changed compared to restic was that rustic always keeps the oldest snapshots if there are not enough snapshots satisfying the --keep-* criteria. For restic, this was added with the mentioned PR about a half year ago. Now rustic and restic behave exactly identically.

@aawsome
Copy link
Member

aawsome commented Feb 1, 2024

FWIW, the logic you are requesting and which has been added recently to restic has been added to rustic here:
bf21f8b#diff-ffefaccfb096399d6312ab3946952e890c6cacb953210caed589cbf7609596aeR230
(snapshots are treated as candidates for a keep-* if they are either the oldest snapshot, the youngest snapshot or if the hour/day/week/.. doesn't match the last processed snapshot - Note that the oldest snapshot is in this list!)

@simonsan simonsan removed the S-triage Status: Waiting for a maintainer to triage this issue/PR label Feb 2, 2024
@rustic-rs rustic-rs locked and limited conversation to collaborators Feb 2, 2024
@simonsan simonsan converted this issue into discussion #1036 Feb 2, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants