Two-way synchronization of data on two servers?

Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike

2 server on FreeBSD (#1 and #2) running rsync'ω, which are in different apartments. Each server has one 500GB hard storing work and personal information.


To do smart sync, which I knew how:
1. When you add/remove/change information on server #1, it should be added/deleted/changed on the server #2.
2. Similarly to item 1 in reverse order.

That's what I did:

On server #2 added in cron the following command:

/usr/local/bin/rsync -avz-e 'ssh -p 22' --partial /hdd/docs/ rsync@78.xx.xx.xx:/hdd/docs/ # from server #1 to server #2
/usr/local/bin/rsync -avz-e 'ssh -p 22' --partial rsync@78.xx.xx.xx:/hdd/docs/ /hdd/docs/ # and Vice versa

The problem arose when I started to add the keys

delete-after Delete files on the slave (#2), which was not found on the master (#1), after synchronization.
You can also use delete-before, delete-during, delete-excluded, and delete.

It turned out that just deleted/changed the first command in the crown file #1 is re-created when you sync #2 to #1 the second team and Vice versa.

Is there a solution?
by | 15 views

3 Answers

0 like 0 dislike
I do so:
ESCDIR=$(echo "$DIR" |sed -e "s,\\([]\\(\\).^\\*\\$\\/&[]\\),\\\\\\\\\\1,g") scp-p $DIR/.lastsync $HOST:$DIR ssh $HOST find $DIR/$SUBDIR -newer $DIR/.lastsync | sed -e "s/$ESCDIR\\///" | \\ rsync --exclude-from=- --delete -av $DIR/$SUBDIR $HOST:$DIR rsync --delete -av $HOST:$DIR/$SUBDIR $DIR rsync --delete -av $DIR/$SUBDIR $HOST:$DIR DATE=`date` echo "$DATE finished Syncing" echo "=====================================================" echo "" touch $DIR/.lastsync 

Implies that during during the Cinca files are not changed and the sink is not interrupted. The latter is easy to fix, but the first without a local db can be done.
0 like 0 dislike
0 like 0 dislike
So the problem is not that during synchronization, something changes, and that one of the options somehow rolled on the second, even if half of the files have already been removed.

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
5 answers
110,608 questions
257,186 answers
36,563 users