simlinks and options

jw schultz jw at
Sat Feb 22 08:58:00 EST 2003

On Fri, Feb 21, 2003 at 12:15:59PM -0400, Carlos Molina Garcia wrote:
> Greetings.
> I wrote a script that make remote backups with rsync. I have 2 main 
> problems with it
> 1) I want that the destination directory (on the repository machine) 
> recreate the backed up file path and it permission (I use -R here )
> 2) Is there a way to "follow" all the links using -R and -a parameters..??
> Currently I am using something like this.
> rsync -al --delete --copy-unsafe-links --rsh=/usr/bin/ssh -R 
> --delete-excluded -vv --delete /etc/* root at

What you want is not /etc/* but /etc or /etc/  With /etc it
will copy the /etc directory (and you won't in this case
need -R.  With /etc/ it copies all the contents of /etc but not
the directory itself and you will want -R or add etc to the
destination path.

Do a echo /etc/* to see what the shell is putting on the
command line to rsync.

> and if I see /etc on the source server
> s -la /etc/runlevels/default/
> total 1
> drwxr-xr-x    2 root     root          216 Feb 12 21:02 .
> drwxr-xr-x    6 root     root          152 Dec  3 11:45 ..
> -rw-r--r--    1 root     root            0 Dec  4 06:51 .keep
> lrwxrwxrwx    1 root     root           15 Feb  9 16:39 gpm -> 
> /etc/init.d/gpm
> lrwxrwxrwx    1 root     root           17 Dec 31  1998 local -> 
> /etc/init.d/local
> lrwxrwxrwx    1 root     root           17 Feb 12 21:02 named -> 
> /etc/init.d/named
> lrwxrwxrwx    1 root     root           20 Dec 31  1998 net.eth0 -> 
> /etc/init.d/net.eth0
> lrwxrwxrwx    1 root     root           20 Dec 31  1998 netmount -> 
> /etc/init.d/netmount
> lrwxrwxrwx    1 root     root           20 Dec 31  1998 sysklogd -> 
> /etc/init.d/sysklogd

Absolute paths all.

Now reread the manpage
              This  tells  rsync to copy the referent of symbolic
              links that point outside the source tree.  Absolute
              symlinks  are also treated like ordinary files, and
              so are any symlinks in the source path itself when
              --relative is used.

Change all those symlinks to to relative and make the above
change and it will do as you want.

> Is there a way to maintain the simlinks that the source server have..??

Yes, don't use --copy-unsafe-links but do use --links which
is included in -a.  That may produce a few links that point
nowhere or that point to non-backup files on the local

> I should use the -R flag to maintain the source server directory 
> structure on the storage server...

How you do that is up to you.

Oh, the term is symlinks, not simlinks.  It is short for
symbolic link :)

	J.W. Schultz            Pegasystems Technologies
	email address:		jw at

		Remember Cernan and Schmitt

More information about the rsync mailing list