Skip to content
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

Support for custom user ID "--cid" (feature) #888

Closed
yhafri opened this issue Mar 17, 2017 · 1 comment
Closed

Support for custom user ID "--cid" (feature) #888

yhafri opened this issue Mar 17, 2017 · 1 comment

Comments

@yhafri
Copy link

yhafri commented Mar 17, 2017

Output of restic version

Any

Expected behavior

We would like to see a new option called --cid (i.e Custom ID).
When a backup succeeds, restic will use the --cid instead of computing one.
It's the caller responsability to provide Unique CID with the same size as restic generated ones.

$ restic --cid=bdbd343940dc1520  -r /tmp/backup backup ~/path.txt

In case of multiple paths to backup, the caller must provides the same number of CID:

Example with two paths:
$ restic --cid=bdbd343940dc1520 --cid=797661759f0bc19e -r /tmp/backup backup ~/path1.txt ~/path2.txt

Actual behavior

By default, restic generates its own ID (see first column below).

$ restic -r /tmp/backup snapshots
enter password for repository:
ID        Date                 Host    Tags   Directory
----------------------------------------------------------------------
40dc1520  2015-05-08 21:38:30  kasimir        /home/user/work
79766175  2015-05-08 21:40:19  kasimir        /home/user/work
bdbd3439  2015-05-08 21:45:17  luigi          /home/art
590c8fc8  2015-05-08 21:47:38  kazik          /srv
9f0bc19e  2015-05-08 21:46:11  luigi          /srv

Rational

As our backups grow more and more, we found ourselves managing 2 types of IDs.
The ones generated by restic, and the ones stored in our legacy database.

Matching between them becomes hard and very cumbersome.
We would like to unify everything by using one, and only one ID.

@yhafri yhafri changed the title Support for custom user "--cid" (feature) Support for custom user ID "--cid" (feature) Mar 17, 2017
@fd0
Copy link
Member

fd0 commented Mar 17, 2017

Thanks for suggesting this issue. The IDs for the snapshots are the file names of the (encrypted) snapshots as stored in the repo, which means the ID is the SHA256 hash of the encrypted snapshot data. That's the way the storage works. Among others, this guarantees (with very high probability) that there are no collisions between two snapshots, even if different machines are involved. This will not change.

If you need your own ID attached to a snapshot, you can use a tag. If that tag happens to be unique, you can use the new tag filtering code to select a snapshot based on a tag, e.g. for restore or ls (combined with the snapshot ID latest):

$ restic backup --tag cid=bdbd343940dc1520 ~/work
[...]
snapshot 084c61e6 saved

$ restic snapshots --tag cid=bdbd343940dc1520
ID        Date                 Host        Tags                      Directory
----------------------------------------------------------------------
084c61e6  2017-03-16 19:49:40  kasimir     cid=bdbd343940dc1520      /home/fd0/work

$ restic ls --tag cid=bdbd343940dc1520 latest
[...]

This even works well with multiple different cid= tags.

I'm going to close this issue for now. You can leave additional comments.

@fd0 fd0 closed this as completed Mar 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants