0

Like many (I think), I have a ~/document directory which I would like to backup periodically to an external drive. ~/document contains also some symlinks to config files and directories, such as ~/.profile and ~/.config/xfce4.

Despite my problem seems pretty ordinary, some backup tools, such as borg and restic, simply do not backup the targets of the symlinks (or so is my understanding). Others instead, such as rsync, have more flexibility. For example, based on this question, I can use:

rsync -a --copy-unsafe-links ~/document/ dest

If my understanding is correct, instead of the symlinks to files and directories, this creates the actual targets into dest. The command is clever enough to copy only targets external to dest and keep the symlinks for targets inside dest, to avoid duplications.

The problem, at this point, is not the backup, but the restoration. When replacing the links with with their targets, the information about links is lost. Therefore, when I restore the backup I will get, say, ~/document/.config/app, and I have to move it to ~/.config/app and to recreate the link to it in ~/document/.

There are some obvious solutions. One is to make a (complex) bash script to manage the backup and forget the dedicated tools. Another solution is to forget using links inside ~/document/ and backup individually each relevant config file and directory to keep. Another possibility is to invert the links. This is to say that it is, for example, ~/.config/app to be a link to ~/document/.config/app and not vice-versa. That seems clever, but I suspect it could get broken soon by update utilities which delete the configuration files and directories and then recreate them.

Eventually, I would like to find a tool that can manage both backup and restoration of symlinks. Does such an utility exist?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.