rsync with mode --delete

Francis.Montagnac at inria.fr Francis.Montagnac at inria.fr
Sun Jun 28 06:58:32 UTC 2020


Hi.

On Sat, 27 Jun 2020 00:23:12 +0700 Budi Janto wrote:
> On 6/23/20 12:37 PM, Francis.Montagnac at inria.fr wrote:
>> If the rsync source path is /mnt/DATA yes, it will remove data on the
>> client, but if the source path is a sub-directory of /mnt/DATA the
>> rsync will fail without doing any deletion.

> Thanks for first information. This is for more detail, which has already
> been done.

> Server side:
> # zfs list
> NAME   USED  AVAIL  REFER  MOUNTPOINT
> pool  4.98T  9.07T  4.98T  /mnt/DATA

> # cat /some/path/rsyncd.conf
> [data]
...
> path = /mnt/DATA
...

> Client side:
> # crontab -l
> 0       */3   	*   	*   	*	/path/to/rsync.sh

> # cat /path/to/rsync.sh
> rsync -avPH --chmod=D755,F644 --delete rsync://xxx.xxx.xxx.xxx/data/

> Any idea or suggestion to prevent client's data loss? Thank you.

The simplest way is probably to:

  - move any files/directories of /mnt/DATA in a subdir.
    Example: /mnt/DATA/data
  - change rsyncd.conf to reflect that

I will do:

  1. stop the rsync daemon on the server
  2. do the move (assuming you have no files matching .?)
     cd /mnt/DATA/
     mkdir .a
     mv * .??* .a
     mv .a data
  3. change rsyncd.conf: path = /mnt/DATA/data
  4. start the rsync daemon
  5. check in dry-run on one client:
     - with /mnt/DATA mounted
     - with /mnt/DATA unmounted

-- 
francis



More information about the rsync mailing list