Dueling rsync scripts?

Bradley Hook bhook at kssb.net
Fri Jun 6 17:29:56 CDT 2008


Part A:
You can push the changes both ways, but you are just asking for data
loss if you don't have some sort of control on who can edit what files
when. The first time you end up with two people modifying the same file
on each server within the same cron window you will get to experience
the issue. You will get the version with the latest time stamp, which
may or may not be what you want. You will quite likely end up
overwriting changes that you intended to have kept and not realize the
mistake until much later.

Part B:
Wrap your cron script in something like what I have below. It could be
modified to touch a file remotely if you are trying to ensure that only
one of the servers is running an instance at any given time.

#!/bin/bash
if [ -f /some-where/rsync-is-running ]; then
	echo "`date` - An instance of rsync is already running!" >>
/some-where/rsync.log
else
	echo "`date` - Starting synchronization" >> /some-where/rsync.log
	touch /some-where/rsync-is-running
# ... your script here ...
	echo "`date` - Finished synchronization" >> /some-where/rsync.log
	rm /some-where/rsync-is-running
fi

Charles Steinkuehler wrote:
> Greg Brooks wrote:
> | Hi all, quick question.
> |
> | Given an FTP server and directory tree on local machine X and an FTP
> server
> | on remote machine Y, I understand that a cron'd rsync script might be the
> | best way to keep changes on X mirrored up to Y. My questions:
> |
> | * Can I mirror the script in reverse so that changes on machine Y
> propagate
> | back to X? (Perhaps running each script every other hour.)
> 
> Yes.  Rsync has several options to let you synchronize just what you
> want.  Update only files that already exist, update only files that are
> newer, etc.  Check out the --update switch, which can probably be used
> to do what you want.
> 
> | * Every now and then, an extraordinary number of files need to be
> | transferred, so a script running once an hour (or whatever) could
> | conceivably bump into another instance of itself running. Issues?
> 
> This is typically handled using a lock-file (or something similar) so
> that only one instance is running at a time.
> 
_______________________________________________
Kclug mailing list
Kclug at kclug.org
http://kclug.org/mailman/listinfo/kclug

-- 
~Bradley Hook
Education Systems Administrator
Kansas State School for the Blind
1100 State Avenue
Kansas City, KS 66102
Voice: (913) 281-3308 ext. 363
Mobile: (913) 645-9958
Facsimile: (913) 281-3104
http://www.kssb.net

******************************************************************************************
Confidentiality Statement:
This message and accompanying documents are covered by the Electronic
Communications Privacy Act, 18 U.S.C. 2510-2521, and contain information
intended for the specified individual(s) only.  This information is
confidential unless explicitly indicated otherwise.  If you are not the
intended recipient or an authorized agent responsible for delivering it
to the intended recipient, you are hereby notified that you have
received this document in error and that any review, dissemination,
copying, or the taking of any action based on the contents of this
information is strictly prohibited.  If you have received this
communication in error, please notify the sender immediately by E-mail,
and delete the original message.
******************************************************************************************


More information about the Kclug mailing list