How do I deal with too many levels of symbolic links?
I suggest you use rsync
rather than cp
to backup data as you want to do it. Rsync has a few options to deal with symlinks. A sym(bolic) link is simply a link to another file. It is a bit like a 'shortcut' in windows language.
-l, --links copy symlinks as symlinks
-L, --copy-links transform symlink into referent file/dir
--copy-unsafe-links only "unsafe" symlinks are transformed
--safe-links ignore symlinks that point outside the tree
-k, --copy-dirlinks transform symlink to dir into referent dir
-K, --keep-dirlinks treat symlinked dir on receiver as dir
-H, --hard-links preserve hard links
Here is an easy example:
sudo rsync --verbose --recursive --links --perms --executability --owner --group --times /media/some-user-name/the-c-drive-you-want /media/some-user-name/the-external-drive
Use the option --dry-run
for a hypothetical run that does not write anything to your external drive.
Read the man rsync
for more information on the different options.
Related videos on Youtube
Anthony
Updated on September 18, 2022Comments
-
Anthony almost 2 years
I'm using Ubuntu Live USB to access my windows files, I'd like to perform a complete, file by file, backup of the Windows
C:
Drive.Since I want everything backed up, I'm doing a copy and paste. Copy the
C:
Drive, Paste it to the external drive.Unfortunately, I'm running into a problem: I get an error message stating
Too many levels of symbolic links
.What does this mean, and how do I fix it?
-
Admin over 11 yearsWhy want to have a backup like that? a backup like that is less useful except the files in
Users
(for OS>Vista)/Documents & settings
(XP) folder. I would suggest to use a disk cloning software.
-
-
Anthony over 11 yearsThis is my first night using Linux, so I really appreciate the detailed answer. Will this "-l, --links copy symlinks as symlinks" command leave directory structure and long file names intact? Also, what exactly is a symlink? Thank you very much
-
don.joey over 11 yearsthe length of file names is irrelevant. directory structure remains intact, but note that the different --links... options differ in whether or not they create a symbolic link on the destination or whether they simply copy what the link referred to. just run the command 'man rsync' in your terminal and you can scroll to more information. Use the --dry-run option to try your command out.
-
don.joey over 11 yearsif you really want a 'bare metal backup' then I agree with @Web-E that cloning software will be more versatile and trustworthy. Remember that permissions and the type of filesystem (ntfs, fat...) also affect your data. If you want a clone of your disk, then clone it, don't 'copy' it. If you want both a copy and a clone, then clone it using a specific tool and copy it using rsync.
-
Anthony over 11 yearsMy main priority is a file by file copy, so I'll try the rsync, thank you very much.
-
don.joey over 11 yearsYou're welcome. Let us know if it worked and if so, please mark the question as answered. Good luck.