77
16
I want to backup my home directory to an external drive nightly using a cron
job to execute rsync
. I am unsure of the exact behavior of rsync
's symbolic link flags.
rsync
's-a
flag includes the-l
flag (i.e. "copy symlinks as symlinks"). Does this just mean it will copy the link or that it will follow the link and copy everything in the link-to directory? I want to avoid that because I have links to directories full of media files that would involve copying hundreds of gigabytes I don't need to back up.- Fearing (but not certain) that
rsync -a
would copy all those media files I instead added the--no-links
flag. This does not seem to be behavior I want. It just ignores copying any link which is problematic because I do have links I want copied (e.g. links to common header files from different project directories). - Assuming #1 above (without the
--no-links
flag) is what I really want and it just copies the link without copying the linked-to files, will the links break when they are backed up? For example I mayrsync
source directory/home/me/projects/misc
to/media/extdrive/backup/home/me/projects/misc
. In this case I assumersync
is not smart enough nor does it try to correct the contents of symlinks for the relative directory changes. Is this correct? This is okay, it doesn't matter if the links are broken in the backup directories so long as they would be fixed and working if such time comes when they need to be restored.
3The -L flag is probably what you want. From the rsync man page on Centos Linux:
I recommend testing this with some sample directories and links to make sure you don't overwrite any data that you don't intend to. Edited to included warning about possible data loss. ;) – Mick T – 2015-10-23T19:22:26.403