rsync and symbolic links
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix administration > rsync and symbolic links




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    rsync and symbolic links  
David Staschover


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-31-06 12:16 AM

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?


Thanks in advance,


David








[ Post a follow-up to this message ]



    Re: rsync and symbolic links  
Michael B. Trausch


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-31-06 12:18 PM

David Staschover wrote in <Tv3fg.31$y47.0@fe10.lga> 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!





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:33 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register