osync icon indicating copy to clipboard operation
osync copied to clipboard

Exclude list delete files from both side

Open godamri opened this issue 5 years ago • 10 comments

Describe the bug Tried to add some list to exclude, but i get them deleted from source and destination

To Reproduce RSYNC_EXCLUDE_FROM="exclude.list"

godamri avatar Jun 13 '20 18:06 godamri

Can you give more details ? Like exactly what you're trying to achieve, osync version used ? config file / command line ?

deajan avatar Jun 26 '20 14:06 deajan

Here is an use case that I have experienced during the evaluation stage of the osync tool (master version) that might be related to this issue:

  • edit the config file and run the osync.sh (for the initial sync of the target)
  • add some exclusions patterns to RSYNC_EXCLUDE_FROM into config file
  • run osync.sh again
  • the files matching the patterns list will be deleted from both target and initiator.

I think that the matching files should be only deleted (excluded) from the target.

However, if the RSYNC_EXCLUDE_FROM is already configured on the first run (initial sync), the matching files will neither be transferred to nor deleted from master subsequently.

victor-vc avatar Jun 26 '20 15:06 victor-vc

Okay I see... That's actually a known issue (see KNOWN ISSUES). No easy way around this one. I'll add a note in the config file.

deajan avatar Jun 27 '20 18:06 deajan

From what I noticed, this is not strictly related to "soft deletion". The files are deleted regardless of "soft deletion" enabled or disabled.

victor-vc avatar Jun 27 '20 19:06 victor-vc

I'm sorry, I have a hard time getting what you're talking about here. Care to make a quick schema of the behavior you're describing ?

deajan avatar Jun 29 '20 07:06 deajan

I just tried the following:

Create a conf file based on the template like

INITIATOR_SYNC_DIR="/tmp/testA"
TARGET_SYNC_DIR="/tmp/testB"

...

RSYNC_EXCLUDE_FROM="exclude.list"

Created the following exclude.list file

*.test

Creating files in directories

touch /tmp/testA/{file1.ext,shouldnotbedeleted1.test}
touch /tmp/testB/{file2.ext,shouldnotbedeleted2.test}

Run osync

Result:

ls testA
file1.ext  file2.ext  shouldnot1.test

ls testB
file1.ext  file2.ext  shouldnot2.test

This is the excpected behavior. Files with extension .test haven't been touched nor deleted by osync. @goDamri, @victor-vc Can you explain the problem you're experiencing this way so I get to know what happens ?

deajan avatar Jun 29 '20 08:06 deajan

Here is the scenario (unexpected behavior):

  • create the test.conf file
INITIATOR_SYNC_DIR="/initiator/folder"
TARGET_SYNC_DIR="ssh://target.host.com//target/folder"
...
SOFT_DELETE=false
  • add some files to the initiator folder touch a.txt b.txt c.test

  • run osync (initial sync) osync.sh /etc/osync/test.conf

Result: all 3 files are synced (i.e. existing in both initiator and target folders)

  • edit test.conf and add the the exclusion pattern RSYNC_EXCLUDE_PATTERN="*.test"

  • run osync again

Result: c.test is deleted from both initiator and target.

victor-vc avatar Jun 29 '20 11:06 victor-vc

Ok, now it's getting clear. osync is statefull, which means it keeps directory changes between runs. If you happen to modify the configuration, you have to reinitialize the statefullness, ie run osync once with --initialize parameter.

I'll add a word to the doc.

deajan avatar Jun 29 '20 11:06 deajan

Yes, it makes sense because if I add RSYNC_EXCLUDE_PATTERN="*.test" in the conf file from the very beginning (prior running the initial sync), the files are preserved on initiator and are not transferred (are excluded) from target.

victor-vc avatar Jun 29 '20 12:06 victor-vc

This was freaking scary... A big blocker bug just before a release. Fortunately, it's just doc updates ;)

deajan avatar Jun 29 '20 12:06 deajan