Hello,
I am new on forum. Firstly, hi to all.
I want to get json output from restic and it gives the output however the issue is snapshot_id is hashed I guess, I need remote snapshot_id name. Can someone tell me what to do get that output?
{
"message_type":"summary",
"files_new":0,
"files_changed":0,
"files_unmodified":15,
"dirs_new":0,
"dirs_changed":0,
"dirs_unmodified":14,
"data_blobs":0,
"tree_blobs":0,
"data_added":0,
"total_files_processed":15,
"total_bytes_processed":13713,
"total_duration":0.856219,
"snapshot_id":"688e40fe1cddd7426f206d8641269e7f0a644fb5f74592a881e8867bc4f9717f"
}
I need snapshot_id like “062c0a26”.
Thanks…
"snapshot_id":"688e40fe1cddd7426f206d8641269e7f0a644fb5f74592a881e8867bc4f9717f"
is snapshot id
if you need so called short id use its first 8 characters:
"short_id":"688e40fe"
1 Like
Can you explain why you “need” the short id? Note that all restic commands also work with the long id, e.g. you can easily call restic ls 688e40fe1cddd7426f206d8641269e7f0a644fb5f74592a881e8867bc4f9717f
- and if you use the json output for scripting, this is actually the preferred way.
If you however need a shorter id for display reasons or something like this, you can easily shorten the id yourself to suit your needs…
1 Like
I didn’t know the long id does the same job as short id. That’s why I asked.
Actually, its vice versa: The short id usually also works - if it is unique. The long id is what uniquely defines the snapshot and is always used internally.
IIRC, you can even use all kind of short ids as long as it uniquely resolves to a long id. For instance in your example 688e40f
, 688e40
, 688e4
, 688e
, 688
might also work - depending on the other existing snapshots. On the other hand, if 688e40fe
isn’t unique, you’d need to use 688e40fe1
or 688e40fe1c
… (until the id is unique).
For scripting, if you already have the long/full id, simply use it and don’t bother any longer about unique ids. Actually, if you give the full id, restic could even optimize the repository access as it no longer needs to scan the repository for matching snapshots. But I don’t think this optimization has been implemented yet…
1 Like
Dear Alex,
I appreciate your time for extra explanation. Thank you. I will keep in mind to use long id.