--- wikid.pl.ORIG 2010-04-26 12:29:43.000000000 -0700 +++ wikid.pl 2010-04-26 13:08:14.000000000 -0700 @@ -367,16 +367,14 @@ } sub sync_files{ - print "Synchronizing Files\n"; - print "Erasing private files ...\n"; - Master_cmd("rm -f $WIKID_HOME/private/*"); - print "Pushing master files to slave...\n"; - Master_cp("$WIKID_HOME/private/*","$WIKID_HOME/private"); + print "Synchronizing master files to slave...\n"; + # Give rsync the --delete flag to make the directories perfectly in sync + Master_cp("$WIKID_HOME/private/","$WIKID_HOME/private/", "--delete"); my $secfile = '/etc/WiKID/security'; if (-f $secfile ) { Master_cp("$secfile","$secfile"); } - Master_cp("$WIKID_HOME/private/*","$WIKID_HOME/private/"); + Master_cp("$WIKID_HOME/private/","$WIKID_HOME/private/"); } sub sync_db{ @@ -387,9 +385,8 @@ print "Erasing slave data...\n"; Master_cmd("rm -rf /var/lib/pgsql/data"); print "Pushing master data to slave...\n"; - Master_cp("/var/lib/pgsql/data", "/var/lib/pgsql/", "-r"); + Master_cp("/var/lib/pgsql/data", "/var/lib/pgsql/"); print "Finalizing sync...\n"; - Master_cmd("chown -R postgres:postgres /var/lib/pgsql/data"); Master_cmd("[ -x /sbin/restorecon ] && /sbin/restorecon /var/lib/pgsql/data"); } @@ -412,7 +409,7 @@ local $SIG{ALRM} = sub { die "Timeout connecting to $replicant{slave_ip}\n" }; alarm 7; # this should be reasonably long enough to get a response back without delaying the master - system("scp $_[2] -i $WIKID_HOME/private/replication.ssh -q $_[0] root\@"."$replicant{\"slave_ip\"}:$_[1]"); + system("rsync $_[2] -a -e'ssh -i $WIKID_HOME/private/replication.ssh' -q $_[0] root\@$replicant{\"slave_ip\"}:$_[1]"); alarm 0; };