[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [K12OSN] rsync with multiple dhcpd servers -- scripting questions



The answer:

I fixed the bug by . . .






















. . . removing " --delete" from line 4 of the script.

Now I have the problem that, if a file has been synced, you cannot delete it.  It reappears at the next sync.

What I want to happen is to go through each user in /home and see which version is most recent (the one on server1 or the one on server2).  Then I want to only rsync from most recent to older, with the "--delete" option to remove files that were deleted recently.

I can imagine having a script (running on server2) that does a local "ls -l /home" and a "ssh server2.ltsp ls -l /home" and compares the modification times and then does the rsync in the appropriate direction for each user's directory.

Can anyone think of a more elegant solution?



On Sun, Oct 12, 2008 at 2:03 PM, Stephen Crampton <SteveSings gmail com> wrote:
At bottom is a script I wrote to sync the files between two K12LTSP servers.  server1 is 192.168.0.254 and server2 is 192.168.0.253.

I put the script in /etc/cron.hourly.  It seems to work, except the log files are not created unless I run the script manually (as root).

I would appreciate any comments/corrections.  Thanks!


---------------------------------------------------------------------------------------------------------------------


#!/bin/bash
LOGFILE="/var/log/rsync.log"
ERRFILE="/var/log/rsync.errors"
RSYNCCMD="rsync -ahtuvz -e ssh --delete"
RSYNC="nice "$RSYNCCMD
DATE=`date`
ps aux | grep -e "$RSYNCCMD" | grep -v grep &&
  echo "We appear to be already running." &&
  sleep 2 &&
  exit -1
echo "" >>$LOGFILE
echo "***********************************************************" >>$LOGFILE
echo "rsync $DATE" >>$LOGFILE
echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv" >>$LOGFILE
echo "" >>$LOGFILE
echo "" >>$ERRFILE
echo "***********************************************************" >>$ERRFILE
echo "rsync $DATE" >>$ERRFILE
echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv" >>$ERRFILE
echo "" >>$ERRFILE
#
$RSYNC server1.ltsp::home /home 1>>$LOGFILE 2>>$ERRFILE
#
$RSYNC /home/ server1.ltsp::home 1>>$LOGFILE 2>>$ERRFILE
#
$RSYNC server1.ltsp::html /var/www/html 1>>$LOGFILE 2>>$ERRFILE
#
$RSYNC /var/www/html/ server1.ltsp::html 1>>$LOGFILE 2>>$ERRFILE
#
$RSYNC server1.ltsp::'etc/passwd etc/shadow etc/group etc/gshadow etc/default/useradd etc/skel etc/login.defs etc/desktop-profiles' /etc 1>>$LOGFILE 2>>$ERRFILE
#
$RSYNC /etc/passwd /etc/shadow /etc/group /etc/gshadow /etc/default/useradd /etc/skel /etc/login.defs /etc/desktop-profiles server1.ltsp::etc 1>>$LOGFILE 2>>$ERRFILE
echo "" >>$LOGFILE
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" >>$LOGFILE
echo "rsync $DATE" >>$LOGFILE
echo "***********************************************************" >>$LOGFILE
echo "" >>$ERRFILE
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" >>$ERRFILE
echo "rsync $DATE" >>$ERRFILE
echo "***********************************************************" >>$ERRFILE
LOCKS='/tmp/gconfd-* /tmp/mapping-* /tmp/orbit-*'
rm -rf $LOCKS
ssh server1.ltsp rm -rf $LOCKS
exit 0



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]