How does restic handle symlinks?


I just realized that I don’t understand how restic handles symlinks.

When I try a command like

restic -r my_repo restore -H $HOST latest -i $FILE --target .

and $FILE is a regular file in the backup of $HOST then restic restores it just fine, however if $FILE is a symlink then nothing gets restored.

Is that the intended behaviour?

I would have expected that I would get a dangling (as I only restored the symlink but not it’s target) symlink, and I am bit surprised that I don’t get any error but also no data…

So what is going on here?

Many thanks!

Documentation Backing up special items and metadata:

Symlinks are archived as symlinks, restic does not follow them. When you restore, you get the same symlink again, with the same link target and the same timestamps.

But the doc says “When you restore, you get the same symlink again”.

Why then do I not get my symlink back?

As I said, I expected a dangling symlink to be restore (not the target), but instead I got nothing at all…

Interesting. I just tried it myself - I backed up a directory which contained some files and a symlink. I then restored that symlink alone with restic restore --target test --verify --include foo/Apa.Ape latest, and it sure is restored as expected:

% ls -la test/foo                                                     
total 0
drwxr-xr-x  3 rawtaz  staff  96 20 Mar 22:09 .
drwxr-xr-x  3 rawtaz  staff  96 20 Mar 22:11 ..
lrwxr-xr-x  1 rawtaz  staff  94 20 Mar 22:11 Apa.Ape -> rare/RARE FLAC/Unreleased and rare tracks/Another Suitcase In Another Hall (Tv Radio Edit).Ape

My best guess off the bat is that you are not supplying the correct path to the symlink you are trying to restore. Can you tell us how you back it up and what the path to it in the directory you back up is?

Of course, it could also be a matter of $FILE not containing what you think :slight_smile:

What is the output of restic version?