restic / restic

Fast, secure, efficient backup program
https://restic.net
BSD 2-Clause "Simplified" License
25.16k stars 1.51k forks source link

restic-rewrite: change snapshot metadata #2654

Open ATLief opened 4 years ago

ATLief commented 4 years ago

Output of restic version restic 0.9.6 compiled with go1.13.4 on linux/amd64

What should restic do differently? Which functionality do you think we should add? restic should have the ability to change the metadata of existing snapshots. Properties that should be modifiable include: Paths, Host, ID, Time, and Tags.

What are you trying to do? Since moving to restic, I have converted previous system backups (from different backup solutions) into restic snapshots with the appropriate metadata. Unfortunately I made a few mistakes with some of the snapshots' Times and Paths. If I'd like to correct those mistakes now, I'd need to restore each snapshot, remove it from restic, and back it up again with the correct metadata.

This also has the unfortunate side effect that when I specify --path, these older snapshots aren't selected for listing for forgetting.

rawtaz commented 4 years ago

@ATLief Thanks, but can you be more specific about your use case? Please give one or a couple of concreted examples of what metadata you want to change, from what and to what.

ATLief commented 4 years ago

@rawtaz

ID Time Host Tags Paths

Current:

a9baf756 2018-08-18 22:11:23 postulate old2,important /mnt/backup/duplicity/1 b69c1e31 2018-08-20 13:00:02 postulate old2,important /mnt/backup/duplicity/2

Desired:

a9baf756 2018-08-18 22:11:23 postulate old2,important / b69c1e31 2018-08-20 13:00:02 postulate old2,important /

Current:

7b9e60da 2020-02-09 15:54:56 postulate new /,/proc/cpuinfo,/proc/mdstat,/proc/meminfo,/proc/partitions 092d5547 2020-02-11 10:04:01 postulate new /,/proc/cpuinfo,/proc/mdstat,/proc/meminfo,/proc/partitions

Desired:

7b9e60da 2020-02-09 15:54:56 postulate new / 092d5547 2020-02-11 10:04:01 postulate new /

Current:

964d8b03 2019-07-31 23:16:06 postulate old / 90ed2cdc 2019-08-31 23:16:16 postulate old /

Desired:

964d8b03 2019-07-21 23:04:01 postulate old / 90ed2cdc 2019-08-21 23:04:01 postulate old /

Current (Hypothetical):

0db2e713 2020-03-01 23:04:01 postulate new / 731e44e0 2020-03-08 23:04:01 postulate new /

Desired (Hypothetical):

2db2e714 2020-03-01 23:04:01 postulate new / 531b44e1 2020-03-08 23:04:01 postulate new /

All without changing the actual content of the snapshots.

MichaelEischer commented 4 years ago

You can already add/remove tags with the tag command. Tampering with the Host and Time field would probably be not to hard to implement. Cosmetically changing the paths should be easy too, but when mounting such a snapshot the files will still be located under their original path.

As the snapshot ID is defined by the hash of all snapshot metadata, there's no way to keep the ID identical across changes or even modify it.

gab50000 commented 8 months ago

I have opened a (draft) pull request which allows rewriting host and time of a snapshot. See #4573

neclepsio commented 6 months ago

@gab50000 are you working on rewriting paths, as the issue asks? Because that's exactly what I just asked in the forum. If not, I would try myself.

MichaelEischer commented 2 months ago

The only thing left here is rewriting the paths. However, that has to wait until we have figured out a general strategy how to handle overwriting paths for a backup/snapshot.