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

Full, machine readable directory structure of a snapshot with one command line call #1060

Closed
chaquotay opened this issue Jun 22, 2017 · 7 comments
Labels
type: feature suggestion suggesting a new feature

Comments

@chaquotay
Copy link
Contributor

I'd like to retrieve a full, machine readable directory structure (directories and files) of a snapshots in as few command line calls as possible, ideally in one call.

Right now it looks like the only way to achieve this is to fetch the snapshot`s subtree id, and recursively walk through all the subtrees, resulting in one command line call per subtree id.

The restic ls command almost yields the information that I try to extract, but not in a machine readable format. So adding support for a machine readable format (natural choice: JSON, with the existing --json switch) to restic ls would fit my needs, but I'm open to other solutions.

@fd0
Copy link
Member

fd0 commented Jun 24, 2017

Thanks for the suggestion, that's a good feature to add. In the meantime you can check if the find command does what you need:

$ restic find --json --snapshot latest '*'
[{"matches":[{"path":"/temp","permissions":"dr-xr-xr-x","type":"dir","mode":2147484013,"mtime":"2017-06-18T18:38:21.866621924+02:00","atime":"2017-06-18T18:38:21.866621824+02:00","ctime":"2017-06-18T18:38:21.86662189+02:00","uid":1000,"gid":100,"device_id":49},{"path":"/temp/file-3435842073965383672","permissions":"-rw-r--r--","type":"file","mode":420,"mtime":"1754-08-30T23:37:13.423622144+00:53","atime":"1754-08-30T23:37:13.423622144+00:53","ctime":"1754-08-30T23:37:13.423622144+00:53","uid":0,"gid":0,"device_id":49,"size":23866961497,"links":1}],"hits":2,"snapshot":"20e9c8f0326b9e0ffea8edef427ba1c01afdb944c8d8d5a0b68b0e37c0e2d53c"}]

The matches are even printed incrementally while restic is working, so you can see it also as a stream of results after the initial [{"matches": characters.

@fd0
Copy link
Member

fd0 commented Jun 24, 2017

What's the desired output format? A huge JSON document (like the trees in the repo) with trees inserted instead of tree IDs? Or a sequence/array of tree objects with an additional attribute path?

@fd0 fd0 added the type: feature suggestion suggesting a new feature label Jun 24, 2017
@chaquotay
Copy link
Contributor Author

At first glance the output of restic find looks promising, but it looks like it doesn't search recursively. Is that correct?

As for the desired output format for restic ls --json: a huge JSON document which reflects the directory structure of the snapshot would be great, since my use case is based on the tree structure. But I guess I could reconstruct the tree from an array with paths as well.

@fd0
Copy link
Member

fd0 commented Jun 24, 2017

I'd prefer a sequence of trees, depth first or so, so the following program doesn't need to parse it all at once.

What's your use case btw? What are you building?

@chaquotay
Copy link
Contributor Author

chaquotay commented Jun 25, 2017

It's more of a ".NET research project", where I want to try newer things (compared to what I do at work), e.g. WPF or Nancy.

Basically it's a snapshot file browser, maybe remotely comparable to the existing fusemount, but for Windows and without the low level filesystem stuff, since I prefer to work with managed runtimes like the CLR or JVM. Right now it's an early prototype, but hopefully it will be usable someday and I'll release it as open-source.

@lloeki
Copy link
Contributor

lloeki commented Jul 6, 2017

@chaquotay sounds interesting! That would definitely help with restic adoption for Windows folks over here.

@MichaelEischer
Copy link
Member

This was implemented in #1953 which was included in restic 0.9.3. Just call restic ls --recursive --json latest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature suggestion suggesting a new feature
Projects
None yet
Development

No branches or pull requests

4 participants