I ran the following command
restic forget --keep-within 4d
based on the description
keep snapshots that were created within duration before the newest (e.g. 1y5m7d)
I expected the behavior to be that any snapshot that’s older than 4 days would be deleted.
however the snapshot below was still kept. Why is that? (Today is October 5th)
ID Date
-----------------------------
508b215a 2018-09-27 08:39
matt
October 5, 2018, 10:51pm
2
Is that the only snapshot remaining?
ID Date
-----------------------------
508b215a 2018-09-27 08:39:54
93b0f94d 2018-09-28 00:00:00
955c8677 2018-09-29 00:00:00
ee3577ac 2018-09-30 10:57:30
c1957486 2018-10-01 00:00:00
7f825290 2018-10-01 00:15:00
52eb74f4 2018-10-01 10:00:49
a8b93732 2018-10-02 00:00:00
cdf46849 2018-10-02 00:15:00
1a1b5a6e 2018-10-03 00:00:00
a2d8659e 2018-10-03 00:15:00
6181fef7 2018-10-04 00:00:00
b9bbf476 2018-10-04 00:15:00
f5620911 2018-10-05 00:00:00
742b0f34 2018-10-05 00:15:00
fd0
October 6, 2018, 9:08am
4
Hey, it’s hard to say what’s going on here. In order to help you, can you please paste the complete output including all parameters you gave to restic? If you can reproduce the issue, it’d be great if you could retry (with --dry-run
) with one of the beta releases (here https://beta.restic.net/restic-v0.9.2-134-g233596f4/ ), because restic will now tell you why it kept a particular snapshot.
Please note that the current date is not relevant for --keep-within
, as the help text says, “keep snapshots that were created within duration before the newest ”. So if you specify four days, that’s four days counting backwards from the newest snapshot in the repo, irrespective of the current day.
1 Like
Thanks Alex, that was it.
I had read the help text a few times, but I guess for some reason I was still unclear.
I think the wording:
“keep snapshots that are older than <duration>
(eg. 1y5m7d) relative to the latest snapshot”
would be more clear. Note that “newest” is less common than “latest”
hope this helps
1 Like
fd0
October 6, 2018, 4:10pm
6
Good idea, thanks! Is anyone up for a pull request? I’m on mobile for the next hours…
There were a lot of references to newest and I’m not sure how far to go with it: https://github.com/restic/restic/pull/2031
1 Like
matt
October 6, 2018, 7:43pm
8
But there are snapshots on 2018-10-05
; why would a snapshot on 2018-09-27
be kept?
fd0
October 6, 2018, 8:11pm
9
I’m not sure what’s going on exactly, and without the complete command line and the output we cannot say. It seems to work now, which is a bit unsatisfying to be honest
1 Like
Oh, I added a directory to the backup later on and when I did the list of snapshots I overlooked it
2 Likes
fd0
October 6, 2018, 8:24pm
11
Ah, thanks a lot for clearing it up!
fd0
October 6, 2018, 8:29pm
12
For the record, I’ve reproduced the situation with the list of snapshot timestamps above, my test repo looked like this:
$ restic snapshots
ID Time Host Tags
---------------------------------------------
b6e61de0 2018-09-27 08:39:54 mopped
f0dd5880 2018-09-28 00:00:00 mopped
e2bfb665 2018-09-29 00:00:00 mopped
3e3ecf6c 2018-09-30 10:57:30 mopped
32b8fc84 2018-10-01 00:00:00 mopped
831fb7d7 2018-10-01 00:15:00 mopped
b3d824af 2018-10-01 10:00:49 mopped
35b8cc27 2018-10-02 00:00:00 mopped
62b7c697 2018-10-02 00:15:00 mopped
54e89850 2018-10-03 00:00:00 mopped
d91dabec 2018-10-03 00:15:00 mopped
cc62c87d 2018-10-04 00:00:00 mopped
768319fc 2018-10-04 00:15:00 mopped
fdb55ad8 2018-10-05 00:00:00 mopped
c65db275 2018-10-05 00:15:00 mopped
---------------------------------------------
15 snapshots
This was the result:
$ restic forget --dry-run --keep-within 4d
Applying Policy: all snapshots within 4d of the newest
snapshots for (host [mopped], paths [/home/fd0/tmp/test]):
keep 9 snapshots:
ID Time Host Tags Reasons Paths
------------------------------------------------------------------------------------
b3d824af 2018-10-01 10:00:49 mopped within 4d /home/fd0/tmp/test
35b8cc27 2018-10-02 00:00:00 mopped within 4d /home/fd0/tmp/test
62b7c697 2018-10-02 00:15:00 mopped within 4d /home/fd0/tmp/test
54e89850 2018-10-03 00:00:00 mopped within 4d /home/fd0/tmp/test
d91dabec 2018-10-03 00:15:00 mopped within 4d /home/fd0/tmp/test
cc62c87d 2018-10-04 00:00:00 mopped within 4d /home/fd0/tmp/test
768319fc 2018-10-04 00:15:00 mopped within 4d /home/fd0/tmp/test
fdb55ad8 2018-10-05 00:00:00 mopped within 4d /home/fd0/tmp/test
c65db275 2018-10-05 00:15:00 mopped within 4d /home/fd0/tmp/test
------------------------------------------------------------------------------------
9 snapshots
remove 6 snapshots:
ID Time Host Tags Paths
-------------------------------------------------------------------------
b6e61de0 2018-09-27 08:39:54 mopped /home/fd0/tmp/test
f0dd5880 2018-09-28 00:00:00 mopped /home/fd0/tmp/test
e2bfb665 2018-09-29 00:00:00 mopped /home/fd0/tmp/test
3e3ecf6c 2018-09-30 10:57:30 mopped /home/fd0/tmp/test
32b8fc84 2018-10-01 00:00:00 mopped /home/fd0/tmp/test
831fb7d7 2018-10-01 00:15:00 mopped /home/fd0/tmp/test
-------------------------------------------------------------------------
6 snapshots
You can see that for this situation, restic would remove the snapshot on 2018-09-27, as expected.
1 Like