I currently have an issue that I'm struggling to resolve regarding symbolic links. I am migrating backups from a Windows server to Debian via rsync, and it seems there are no options to have the symbolic links be recreated to point to the equivalent locations in the destination.
All the solutions to recursively fix symbolic links I have found, all seem to only work if the links all point to targets in the same file system.
The source destination is an ntfs partition via iscsi that my windows machine uses for backups, So changing all the symbolic links in the source location to relative before the transfer is not an option. The source must be left untouched and considered read only, Until The new backup server is up and running, And tested to be working.
What I'm looking for is a solution to reconnect the symbolic links at the destination, As Demonstrated below.
symlinks at source: /mnt/fs1/backup/v1/linkToDir1 -> /mnt/fs1/backup/data/dir1 /mnt/fs1/backup/v2/linkToDir2 -> /mnt/fs1/backup/data/dir2 symlinks at destination: /mnt/fs2/backup/v1/linkToDir1 -> /mnt/fs2/backup/data/dir1 /mnt/fs2/backup/v2/linkToDir2 -> /mnt/fs2/backup/data/dir2 At the moment, This is all i am getting.
symlinks at destination: /mnt/fs2/backup/v1/linkToDir1 -> /mnt/fs1/backup/data/dir1 /mnt/fs2/backup/v2/linkToDir2 -> /mnt/fs1/backup/data/dir2 As you can see, the problem is that the symlinks are pointing to the first file system, Not to its corresponding target in the new location.
I found this command as its description sounded like it was just what I needed. As stated by the poster, it would also be able to handle special characters and spaces.
find . -type l -exec printf "ln --no-target-directory -srf -- %q %q\n" {} {} \; | bash Getting rid of | bash To preview the output, it looked like it was going to work
ln --no-target-directory -srf -- ./GAMEBOX-V2/.directory_pool/F1/F1RgpLPbLL17134735891344751328/aida32pe_393 ./GAMEBOX-V2/.directory_pool/F1/F1RgpLPbLL17134735891344751328/aida32pe_393 But looking at the links, It made itself relative from file system 1 mount point.
symlinks: /mnt/fs2/backup/v1/linkToDir1 -> /../../fs1/backup/data/dir1 /mnt/fs2/backup/v2/linkToDir2 -> /../../fs1/backup/data/dir2 Can anyone think of a solution that exists that can, recursively find absolute Symlinks starting at the directory of interest, Read them, and chop off the beginning of the path to make it relative to its new home and replace the old dangling symlink.
Am I on the right track and just got something wrong, or have I completely misunderstood somthing and ended up far out into the woods?
Even if there's a copy tool that does this while copying, I wouldn't mind transferring all the data again if it just means it works. The backup software I'm using is urbackup, and the only way to get the new backup server operational is for the simlinks to be fixed, as it must maintain its directory structure.