Restore --files-from

Hello!

I have been looking around the documentation and the forum but I have not found anything about using --files-from when restoring. Is there any way to make, maybe an array or something like that to make restic restore multiple files/dirs at the same time without restoring a full snapshot? What I’m trying to do is to restore multiple files/dirs using a text file to retrieve the locations (like using backup with --files-from). So far I have tried creating a temp var restore=$(cat /path/to/text/file.txt) and then executing restic restore --include "$(echo $restore)" [snapshotID] -t /tmp/restic_restore without any luck. At first there was a message that says: Fatal: more than one snapshot ID specified, and using $(echo $restore) got rid of it; now it says restoring to /tmp/restic_restore but when I check the restic_restore directory, it doesn’t have anything in it.

The reason why I need an “array” is to make this process automatically. I have this awful script to backup using restic and I want to make the script to use diff when indicated to make a temporary text file which will contain every removed file, and then use --include to restore every file that was removed from the previous snapshot (comparing to latest).

The perfect solution would be to have the option to use --files-from when restoring but if there is another way, I would appreciate the help.

I think you need to pass --include for every file/location you want to restore.
restic restore --include picture1.jpg --include picture2.jpg [snapshotID]

1 Like

Oh man, you gave me an idea. I totally forgot I could include the flag for every line using awk like this:

torestore=$(echo $(awk '{ printf "--include "; print }' file.txt))
restic restore $torestore 87a87a87 -t /tmp/restic_restore

Result:

restic restore --include /home/sulfuror/test1 --include /home/sulfuror/test2 87a87a87 -t /tmp/restic_restore

Thanks a lot!

1 Like