Is it possible to extract a list of specific paths at once?

Problem:

  1. I accidentally corrupted about 50% of my video files (all backed up using restic.)
  2. It would take an extremely long time to completely erase and rebuild the video library from a full restic restore (many days easily.)
  3. I only want to pull out the files that I know got corrupted.
  4. In the documentation, I could only find instructions for extracting one specific directory out of a snapshot.

Question:

Is it possible to copy + paste a list of of --include files, similar to the command provided in docs?

restic -r /srv/restic-repo restore 79766175 --target /tmp/restore-work --include /work/foo

(found in Restoring from backup — restic 0.16.2 documentation)

Thanks

Maybe just write a script which adds the --include options?

You may also try out rustic (disclaimer: I’m the author) which has a restore command which checks existing files and only restores what’s missing or different. That way you wouldn’t need a list of corrupted files but can let rustic find out which files are corrupted and only restore them. Moreover, if you have files where only parts are corrupted, also only the wring parts are restored… I don’t know how your files are corrupted but this could be interesting for large files. Use rustic restore --dry-run to see what it would do.

2 Likes

Maybe just write a script which adds the --include options?

Can you just manually put together a command that has all of them at once? like

restic -r /srv/restic-repo restore 79766175 --target /tmp/restore-work --include /work/foo --include /work/hoo --include /work.goo

AFAIK this works as you expect it - I was just proposing you write a script which takes a plain list of dirs and creates that command for you.

Note that restic isn’t able to do in-place restores - it assumes that /tmp/restore-work is empty in your case. You have to manually move/copy your restored content to the desired place.

1 Like

Well, I wrote the script, and made the command, but the command is this long:

How do you break up such a long command so bash will take it?

I tried writing a little shell script, written as:

#!/bin/bash

sudo restic -r /data/extdrive/restic-repo restore 8c6d5ab2 --target /data/extdrive/dump --password-file /data/sdcard/documents/resticpass.txt --include '/work/foo'
sudo restic -r /data/extdrive/restic-repo restore 8c6d5ab2 --target /data/extdrive/dump --password-file /data/sdcard/documents/resticpass.txt --include '/work/hoo'
sudo restic -r /data/extdrive/restic-repo restore 8c6d5ab2 --target /data/extdrive/dump --password-file /data/sdcard/documents/resticpass.txt --include '/work/goo'

The output came out:

Fatal: unable to open repository at /data/extdrive/restic-repo: ReadDir: open /data/extdrive/restic-repo/keys: input/output error
Fatal: unable to open repository at /data/extdrive/restic-repo: ReadDir: open /data/extdrive/restic-repo/keys: input/output error
extract.sh: line 66: unexpected EOF while looking for matching `''
extract.sh: line 67: syntax error: unexpected end of file

The text was copied into nano from Windows via SSH, and then I ran dos2unix to try to fix carriage return errors, but it didn’t help the errors I was getting.

Any ideas?

I figured it out. It turns out that quite simply the repo had been mounted to a folder already, which is impossible to unmount if you close the SSH session. It worked after resetting the nas.