-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Avoid choosing parent snapshot newer than time of current snapshot #3619
Avoid choosing parent snapshot newer than time of current snapshot #3619
Conversation
78a1a29
to
879d563
Compare
A few other notes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea to only pick older snapshots as parent snapshot. However, regarding the implementation I think it's currently too much code duplication. See the comment for a suggestion.
Document this code review feedback I got for other contributors.
Currently, `restic backup` (if a `--parent` is not provided) will choose the most recent matching snapshot as the parent snapshot. This makes sense in the usual case, where we tag the snapshot-being-created with the current time. However, this doesn't make sense if the user has passed `--time` and is currently creating a snapshot older than the latest snapshot. Instead, choose the most recent snapshot which is not newer than the snapshot-being-created's timestamp, to avoid any time travel. Impetus for this change: I'm using restic for the first time! I have a number of existing BTRFS snapshots I am backing up via restic to serve as my initial set of backups. I initially `restic backup`'d the most recent snapshot to test, then started backing up each of the other snapshots. I noticed in `restic cat snapshot <id>` output that all the remaining snapshots have the most recent as the parent.
879d563
to
058dfc2
Compare
Thank you for the review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I've added a small commit to rename the timestamp
variable to timestampLimit
to make its meaning a bit clearer from the name.
What does this PR change? What problem does it solve?
Currently,
restic backup
(if a--parent
is not provided)will choose the most recent matching snapshot as the parent snapshot.
This makes sense in the usual case,
where we tag the snapshot-being-created with the current time.
However, this doesn't make sense if the user has passed
--time
and is currently creating a snapshot older than the latest snapshot.
Instead, choose the most recent snapshot
which is not newer than the snapshot-being-created's timestamp,
to avoid any time travel.
Impetus for this change:
I'm using restic for the first time!
I have a number of existing BTRFS snapshots
I am backing up via restic to serve as my initial set of backups.
I initially
restic backup
'd the most recent snapshot to test,then started backing up each of the other snapshots.
I noticed in
restic cat snapshot <id>
outputthat all the remaining snapshots have the most recent as the parent.
Was the change previously discussed in an issue or on the forum?
Not AFAIK. I looked through previous issues on GitHub and the forum,
and there are a number of issues which discuss making parent selection smarter in general,
but I did not see any that are specifically about the interaction of parent selection with time.
Since it was a fairly straightforward fix, opted to open a PR directly
but happy to defer to an issue if discussion is needed.
Checklist
changelog/unreleased/
that describes the changes for our users (see template).gofmt
on the code in all commits.