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 [email protected] http://kclug.org/mailman/listinfo/kclug