Restore specific folder with spaces in the path

I am trying restore a specific directory from a snapshot of /storage/media

The full path of the directory I am trying to restore is:
"/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]"

I checked the snapshot I am trying to restore from with restic ls
I tried with both the path inside of quotes and without and escaped

restic ls latest /storage/media/tvshows/X-Men\ -\ The\ Animated\ Series\ \(1992\)\ \[tvdbid-76115\]

snapshot 370f0c5c of [/storage/media] filtered by [/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]/] at 2024-02-08 01:52:06.884960471 +0000 UTC):
/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]
/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]/Season 01
/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]/Season 02
/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]/Season 03
/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]/Season 04
/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]/Season 05
restic ls latest "/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]"

snapshot 370f0c5c of [/storage/media] filtered by [/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]] at 2024-02-08 01:52:06.884960471 +0000 UTC):
/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]
/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]/Season 01
/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]/Season 02
/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]/Season 03
/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]/Season 04
/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]/Season 05

However I could not get restic to restore the folder, I tried both of the commands below and neither restored any files

restic restore latest --target /storage/restore/ --include /storage/media/tvshows/X-Men\ -\ The\ Animated\ Series\ \(1992\)\ \[tvdbid-76115\]
restic restore latest --target /storage/restore/ --include "/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]/"

I have assumed that this is related to spaces and square brackets in the path but I am unsure, would appreciate any insight or advice about what I am doing wrong.

1 Like

ls only performs a simple string match, whereas restore interprets the --include patterns as glob patterns (filepath package - path/filepath - Go Packages). That is you have escape the square brackets. \\\[tvdbid-76115\] should work. Or use the subpath syntax introduced by a recent restic version:

restic restore --target /storage/restore/ "latest:/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]"
2 Likes

Thanks for the response, Using your advice I have been able to restore the files with both methods

restic restore latest --target /storage/restore/ --include X-Men\ -\ The\ Animated\ Series\ \(1992\)\ \\\[tvdbid-76115\\\]/

And

restic restore --target /storage/restore/ "latest:/storage/media/tvshows/X-Men - The Animated Series (1992) [tvdbid-76115]"

I just want to clarify one more thing about the second command. When I used the subpath I noticed it does not restore the directory given as the subpath but only the what is inside that directory.

Is is possible using the subpath syntax to also restore that directory? Or would I need to combine --include with the parent directory "latest:/storage/media/tvshows".

1 Like

No, that’s not possible with the subpath syntax.

Either that, or just extend the --target path accordingly.

1 Like