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

Improve output for restic find #2072

Closed
fbarbeira opened this issue Nov 5, 2018 · 3 comments · Fixed by #2271
Closed

Improve output for restic find #2072

fbarbeira opened this issue Nov 5, 2018 · 3 comments · Fixed by #2271
Labels
help: good first issue easy issue to get started with for beginners (both Go and restic) type: feature suggestion suggesting a new feature

Comments

@fbarbeira
Copy link

Output of restic version

restic 0.9.3 compiled with go1.11.1 on linux/amd64

What should restic do differently? Which functionality do you think we should add?

Every time I try to find a particular file, I execute the command:

# restic find myfile.php
repository 285d013e opened successfully, password is correct
Found matching entries in snapshot 08364c47
/usr/home/myfile.php

Found matching entries in snapshot 11cb608b
/usr/home/myfile.php

Found matching entries in snapshot 1a1e12d9
/usr/home/myfile.php
[...]
#

After that, I have to run the command restic snapshots to know when the snapshot 11cb608b was taken. So I have to run two commands to know exactly the snapshot I need to restore.

It would be very useful if the restic find command output the snapshot date as well as snapshot id, some like this for example:

# restic find myfile.php
repository 285d013e opened successfully, password is correct
Found matching entries in snapshot 08364c47 - 2018-10-23 04:11:05

/usr/home/myfile.php

Found matching entries in snapshot 11cb608b - 2018-10-24 04:11:04
/usr/home/myfile.php

Found matching entries in snapshot 1a1e12d9 - 2018-10-28 04:11:19
/usr/home/myfile.php
[...]
#

Another option is to combine in some way the output of snapshots --compact with the output of find.

# bin/restic_v0.9.3-57-gc0572ca1_linux_amd64 snapshots --compact
repository 35bee826 opened successfully, password is correct
ID        Time                 Host                  Tags
-----------------------------------------------------------
8945cf19  2018-08-15 22:50:03  xxxxxxxxxxxx
01f5b1cf  2018-08-16 07:48:06  xxxxxxxxxxxx
1cf4ec94  2018-08-18 10:28:54  xxxxxxxxxxxx
701c2b2f  2018-08-20 07:11:26  xxxxxxxxxxxx
18d3396d  2018-08-21 07:39:31  xxxxxxxxxxxx
8457abc4  2018-08-22 07:22:04  xxxxxxxxxxxx
bf1074f8  2018-08-23 07:21:35  xxxxxxxxxxxx
9fd3c14f  2018-08-24 07:49:50  xxxxxxxxxxxx
e93b0a12  2018-08-27 07:24:22  xxxxxxxxxxxx
b1bc35db  2018-08-28 07:41:10  xxxxxxxxxxxx

Did restic help you or made you happy in any way?

Very happy!! really good piece of software!

@cdhowie
Copy link
Contributor

cdhowie commented Nov 16, 2018

You can hack this with the --json option alongside jq, a utility for manipulating and querying JSON streams.

restic find --json myfile.php | jq -r '.[].snapshot' | xargs restic snapshots -c

Caveats:

  • You can't supply the password on the console because restic reads the password from standard input, instead of opening /dev/tty. (Since you're running restic twice, you'd have to enter it twice anyway.)
  • This discards the list of which files were found in which snapshot.

@fd0
Copy link
Member

fd0 commented Apr 25, 2019

Ah, good idea actually. I'm labelling this as a feature request. If anyone is up to do it and improve the output of the find command, please submit a PR :)

@fd0 fd0 added type: feature suggestion suggesting a new feature help: good first issue easy issue to get started with for beginners (both Go and restic) labels Apr 25, 2019
@cdhowie
Copy link
Contributor

cdhowie commented Apr 26, 2019

If we're adding the date then it would probably make sense to order the output by date as well. To do this, I would assume we just need to sort the list of snapshots by timestamp before walking each one. If we do that, we have to decide whether to sort ascending or descending. The advantage of each is:

  • Ascending: the newest snapshots are at the bottom, which is the natural place one would expect them to be.
  • Descending: the output can be piped through head to display the most recent snapshots containing the sought-after file quickly, and then restic can abort the operation, saving time.

@fd0 fd0 changed the title Restic find output snapshot date as well as snapshot ID. Improve output for restic find Apr 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help: good first issue easy issue to get started with for beginners (both Go and restic) type: feature suggestion suggesting a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants