Yet another rsync incremental thread

macuserfr macuserfr at
Tue Jul 29 11:10:56 GMT 2008

Hello there!

Le 28 juil. 08 à 16:24, Matt McCutchen a écrit :
> (This original message doesn't seem to have gone to the list.)

Actually it is here 
  , but I messed around mail replies. Dunno exactly what I did...  
Doesn't matter.
> My guess is that the script is running but failing, and silently  
> because
> the rsync daemon redirects its stdout and stderr to /dev/null.  One of
> the first things a pre-xfer or post-xfer script should do is redirect
> its stdout and stderr to a log file somewhere that you can review in
> case of problems.  In bash, the code for that is:
> exec >>/PATH/TO/LOG 2>&1
> (I don't know tcsh.)

I've tried this pertinent suggestion. Unfortunately FreeNAS doesn't  
have bash built-in and exec works a little bit different in tcsh.
I found how to have a log of it like this:

freenas:/mnt/data/serveuranm# cat /var/etc/rsyncd.conf
syslog facility = local4
list = no
port = 873
pid file = /var/run/
uid = rsync

comment = Sauvegarde du serveur ANM
path = /mnt/data/serveuranm/
list = true
max connections = 0
read only = false
uid = serveuranm
gid = rsync
post-xfer exec = /mnt/data/ $RSYNC_HOST_NAME >& /var/log/ 

  >& in tcsh redirects stdout and stderr, like cmd > file 2>&1 in  
bash. I've also tested launching the script with this exact command  
(just replacing the $RSYNC_HOST_NAME, of course). It runs fine and  
logs activity to /var/log/timestamp.log as expected

> And why the failure?  Your script seems to assume a particular working
> directory, because it goes looking for "data" and "backup" in that
> directory.  Note that it will inherit the working directory in which
> "rsync --daemon" was run to start the daemon.  If that isn't what your
> script wants, add an appropriate "cd" command.

Good remark as well. I've changed the script to cd to the right  
directory before executing commands. Current version looks like this:

freenas:/mnt/data/serveuranm# cat /mnt/data/
#exec $0 >& /var/log/timestamp.log
#Turn on debug info
set DEBUG = 0

#Check if we have the good arg number
if( $# < 1 || $# > 1 ) then
	echo "Usage: $0 <name_of_backuped_host>"

#Name of the backup mount (partition)
set MOUNTNAME = data

#Change to working directory
cd /mnt/$MOUNTNAME/$1

if( $status ) then
	echo "Directory /mnt/$MOUNTNAME/$1 does not exist"

echo $PWD
#cd /mnt/$MOUNTNAME/$1
#echo $PWD

#Name of the backup directory
set BACKUP = backup

#Check if the backup directory exists
if( ! ( -e $BACKUP ) ) then
         echo "Directory backup is missing"

#Set up useful variables
set DATE = `date +"%Y-%m-%d-%H%M%S"`
set AVAIL = `df | grep $MOUNTNAME | awk -F' ' '{print $4}'`
set SIZE = `du -s $BACKUP | awk -F' ' '{print $1}'`

if ( $DEBUG ) then
	echo "DATE = $DATE \

if( ! ( -e lastest ) ) then
	mv -f $BACKUP lastest
         mv -f lastest $1$DATE
         mv -f $BACKUP lastest
while ( $AVAIL < $SIZE )
	rm -Rf `ls -1 | grep $1 | head -n 1`
unset *
echo "Rotation successful"

Note that I forced it to echo something if it runs, in all cases. I  
also tested the changes on the script running it alone. All works fine  
when running from any directory.
With all those modifications, the result is always the same. The  
script isn't called. I can say  it for sure now, log file still remain  

I also checked permission on the log file. Everyone have access to / 
var/log directory and timestamp.log is 666 so writable by anyone.

Do you already used post-xfer with plain rsync? I don't know why, I  
think this is why it's not working.

Or maybe I should specify explicitly the user in rsync command in  
cygwin? I don't really think so, because client size fullfil it's  
policy. It opens the connection with the server, push all the content  
and close connection like a charm. If there was an username pb, it  
wouldn't even transfer files, would it?

Thanks indeed for the help,


More information about the rsync mailing list