[Csync2] Can csync2 delete files/folders on destination host that do not exist on source?

Lars Ellenberg lars.ellenberg at linbit.com
Sat Oct 27 13:34:12 CEST 2012


On Fri, Oct 26, 2012 at 05:10:25PM +0300, Ali Nebi wrote:
> Hi,
> 
> I'm new to csync2 and i'm just started using it in our environment for
> synchronization of files. I was using rsync for syncing, but wanted to test
> csync2 and to learn how it works. I got it working just fine regarding sync
> together with lsyncd, but I have a question regarding deleting
> files/folders from destination host that do not on source.
> 
> Using rsync I can keep files/folders in sync including '--delete' option.
> This way rsync delete from destination host everything that do not exist on
> source host. Can csync2 do same?

csync2 does only ever push those *changes* it is aware of.

At some point it recorded a "local state" into its data base.
At a later point, it verifies the then current local state against the
recorded state.
The *changes* in this local state are then pushed to the peer(s).

Which means, for csync2, to push out a "delete", it needs to be aware
that there had been a deletion. You need to tell it that at some point,
there had been a local file, but now it is no longer...

There are two ways to achieve that.
To "delete remotely", you could locally mark as dirty a file that does
not exist:
	csync2 -m this-file-exists-only-on-peer
	csync2 -uv this-file-exists-only-on-peer

To make the peer(s) look like the node you chose to be master,
on all nodes do:
  csync2 -cIr /
on the master do:
  csync2 -TUIX
  csync2 -uv
(that is not something you should do as normal operation,
 but only on initial setup, or when integrating a new node,
 possibly occasionally as maintenance).

> I run following test:
> 
> on host1 i create:
> 
> /var/www/html/test1
> /var/www/html/test2
> 
> They are successfully synced to host2. Now on host2 i create
> 
> /var/www/html/test3
> 
> And on host1 i run sync again, what i see is that 'test3' folder is not
> deleted on host2.

Of course.

> They I decided on host1 to create one more folder:
> 
> /var/www/html/test4.
> 
> This new folder was synced to host2, but  'test3' folder is still not
> removed. Is there a way to do this using csync2?

See above: csync2 is push only, and it pushes changes that happened locally.

Test3 never existed, so it was not deleted locally, no change to test3,
nothing to push out...

But it is symetrical, so host2 had been expected to sync its test3
folder over to host1... then, if you delete it on host1 again, that
would be propagated back to host2.

If you want host2 to always be "slave", you can configure it so,
but you still need to trigger pushes (csync2 -x runs) on it,
which would then make host1 aware of the creation of test3,
but refuse it.
On the next push from host1 to host2 it would be deleted.


-- 
: Lars Ellenberg
: LINBIT | Your Way to High Availability
: DRBD/HA support and consulting http://www.linbit.com

DRBD® and LINBIT® are registered trademarks of LINBIT, Austria.


More information about the Csync2 mailing list