Re: rsync and symbolic links
- From: "Michael B. Trausch" <michael.trausch.no.spam@xxxxxxxxxxx>
- Date: Wed, 31 May 2006 02:35:31 -0400
David Staschover wrote in <Tv3fg.31$y47.0@xxxxxxxx> on Tue, May 30 2006
18:17:
I am using rsync as a backup method to synchronize files between 2 linux
computers.
However, no matter what options I use, the absolute path goes away on the
remote system. It is very important for us to maintain the absolute path,
in case we need to switch to the backup server.
For example:
We are using rsync to copy symbolic link "/filename", to
"/backup/filename" on the backup server.
Here's what happens to the file:
lrwxrwxrwx 1 root root 40 Nov 2 2005 filename ->
/path/to/file becomes
lrwxrwxrwx 1 root root 40 Nov 2 2005 filename ->
path/to/file
Is there any way to retain the complete path on the backup server?
Is there any way to just make the symlink use a relative path, instead of an
absolute one? If you are putting the directory tree on the same place on
the backup server, that should work.
What I find rather interesting is that the file size of the symlink _should_
change if the path is changing:
fd0man@fd0man-laptop:~$ ln -s /path/to/file file
fd0man@fd0man-laptop:~$ ln -s path/to/file file2
fd0man@fd0man-laptop:~$ ls -l file*
lrwxrwxrwx 1 fd0man fd0man 13 2006-05-31 02:29 file -> /path/to/file
lrwxrwxrwx 1 fd0man fd0man 12 2006-05-31 02:29 file2 -> path/to/file
fd0man@fd0man-laptop:~$
As you can see, the file size is different in both situations -- the
file "size" of a symlink is actually just the count of characters to the
path in question.
That having been said, the path ".." in the root directory is always the
root directory, so if you run "cd .." in the root directory, you will stay
in the root directory. That means that while it may be ugly to do so, you
could actually have a symlink point to a seemingly non-existant location
and it will still work, for example, if your tree on the backup server is
in a different location in the filesystem then on the original.
Given that, the following should work:
fd0man@fd0man-laptop:~$ pwd
/home/fd0man
fd0man@fd0man-laptop:~$ ln -s ../../../../../../../usr usr-dir
fd0man@fd0man-laptop:~$ ls -l usr*
lrwxrwxrwx 1 fd0man fd0man 24 2006-05-31 02:33
usr-dir -> ../../../../../../../usr
fd0man@fd0man-laptop:~$ cd usr-dir
fd0man@fd0man-laptop:~/usr-dir$ pwd
/home/fd0man/usr-dir
fd0man@fd0man-laptop:~/usr-dir$ ls
bin games include java lib lib64 local sbin share src X11R6
fd0man@fd0man-laptop:~/usr-dir$ cd ..
fd0man@fd0man-laptop:~$ ls -l usr*
lrwxrwxrwx 1 fd0man fd0man 24 2006-05-31 02:33
usr-dir -> ../../../../../../../usr
fd0man@fd0man-laptop:~$
Of course, the actual relative path in this situation is only ../../usr, but
the symlink has extra, redundant '..' directories so that it can be moved
up to 7 directories away from the root directory and still be functional.
HTH,
Mike
--
Registered Linux User #417338, machine #325045.
A 2400 baud modem makes you want to get out and push!
.
- References:
- rsync and symbolic links
- From: David Staschover
- rsync and symbolic links
- Prev by Date: rsync and symbolic links
- Next by Date: /var out of disk space, but not really
- Previous by thread: rsync and symbolic links
- Next by thread: /var out of disk space, but not really
- Index(es):
Relevant Pages
|
|