LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-24-2011, 04:57 PM   #1
keviny22
LQ Newbie
 
Registered: Oct 2008
Posts: 4

Rep: Reputation: 0
rsync behavior with symlinks


I am having issues with getting rsync to operate the way i am expecting it to with symlinks, any advice would be greatly appreciated.

I am trying to do an rsync that includes a symlink in a folder. I only want the symlink to change on the destination if the mod time of the symlink on the source is newer. The behavior i am seeing is that the symlink on the destination is always updated to match the source regardless of the mod time.

Here is the command I am passing:
Code:
rsync --links --update --archive --exclude "*/" /var/tmp/links/* -e ssh user@dest.example.com:/var/tmp/links/
 
Old 02-25-2011, 02:26 PM   #2
lrtward
Member
 
Registered: Feb 2011
Distribution: CentOS, Ubuntu
Posts: 97

Rep: Reputation: 9
Are you 100% certain that's what's happening?

I did some testing here and what I see is that the original file and the rsync'd file have the same timestamps; that is, changes to the original file cause the timestamp to be updated and the updated time is carried over to the rsync destination. The symlink has the same timestamp as the original file.

I think an example will show it more clearly:
Code:
$ ls -l
-rw-rw-r-- 1 ltward ltward   16 Feb 25 15:13 thefile

$ date
Fri Feb 25 15:15:30 EST 2011

$ ln thefile linkfile
$ ls -l
-rw-rw-r-- 2 ltward ltward   16 Feb 25 15:13 linkfile
-rw-rw-r-- 2 ltward ltward   16 Feb 25 15:13 thefile
So here the symlink has the same timestamp as the "real" file.
Now I make a directory and rsync to it.

Code:
$ mkdir syncdir
$ date
Fri Feb 25 15:17:01 EST 2011

$ rsync * --links --update --archive --exclude 'syncdir' syncdir
$ ls -l syncdir
-rw-rw-r-- 1 ltward ltward   16 Feb 25 15:13 linkfile
-rw-rw-r-- 1 ltward ltward   16 Feb 25 15:13 thefile
Now my symlink and real file at the rsync destination have the same timestamp as the "real" file.
I'll edit the original file and see if that affects the symlink or the rsync'd symlink.

Code:
$ date
Fri Feb 25 15:19:00 EST 2011
$ vi thefile
$ ls -l
-rw-rw-r-- 2 ltward ltward   21 Feb 25 15:19 linkfile
drwxrwxr-x 3 ltward ltward 4096 Feb 25 15:17 syncdir
-rw-rw-r-- 2 ltward ltward   21 Feb 25 15:19 thefile

$ date
Fri Feb 25 15:20:07 EST 2011
$ rsync * --links --update --archive --exclude 'syncdir' syncdir
$ ls -l syncdir
-rw-rw-r-- 1 ltward ltward   21 Feb 25 15:19 linkfile
-rw-rw-r-- 1 ltward ltward   21 Feb 25 15:19 thefile
So my rsync'd symlink file is keeping the timestamp of the "real" file.
I'm on CentOS 5.5

As long as your symlink points to the correct file, does it matter what the timestamp is?
 
Old 02-28-2011, 12:59 PM   #3
keviny22
LQ Newbie
 
Registered: Oct 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks for the response, here is a bit more detail and the specific example.
Here you see that on two servers, we have the same link called honda.link pointing to two different files.
The date of the link on dest.example.com is newer
Code:
[root@source.example.com links]# ls -l
-rw------- 1 root root    0 Feb 28 10:45 accord.file
-rw------- 1 root root    0 Feb 28 10:45 civic.file
lrwxrwxrwx 1 root root   10 Feb 28 10:46 honda.link -> civic.file

[root@dest.example.com links]# ls -l
-rw------- 1 root root    0 Feb 28 10:46 accord.file
-rw------- 1 root root    0 Feb 28 10:46 civic.file
lrwxrwxrwx 1 root root   11 Feb 28 10:47 honda.link -> accord.file
Now I rsync
Code:
[root@source.example.com links]# rsync --links --update --archive --exclude "*/" /var/tmp/links/* -e ssh root@dest.example.com:/var/tmp/links/
Looking at dest.example.com the link changed to match source.example.com even though the link on dest.example.com had a newer timestamp.
Code:
[root@source.example.com links]# ls -l
-rw------- 1 root root  0 Feb 28 10:45 accord.file
-rw------- 1 root root  0 Feb 28 10:45 civic.file
lrwxrwxrwx 1 root root 10 Feb 28 10:46 honda.link -> civic.file

[root@dest.example.com links]# ls -l
-rw------- 1 root root  0 Feb 28 10:46 accord.file
-rw------- 1 root root  0 Feb 28 10:46 civic.file
lrwxrwxrwx 1 root root 10 Feb 28 10:48 honda.link -> civic.file
I would expect that the link on the dest.example.com would be skipped because it is newer
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] rsync fails in cron - ssh key prob for rsync? jonathansfl Linux - Server 6 12-09-2010 09:48 AM
Could I run rsync to download files from a server without rsync daemon? Richard.Yang Linux - Software 1 09-18-2009 04:08 AM
inconsistent behavior of rsync for backup gael Linux - Software 17 04-20-2009 09:28 AM
Strange behavior of rsync w.r.t filename cae jjge Linux - Software 2 09-25-2008 03:03 PM
Changing behavior of pwd with symlinks rose_bud4201 Linux - Software 2 02-17-2005 03:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration