Skip to content

Destination DIR deleted on using --exclude-if-present flag #4523

Open

Description

@SubhashBose

What is the problem you are having with rclone?

if I have a directory tree like this both in local and remote

dir1/
dir1/file1.txt
dir1/dir2/
dir1/dir2/file2.txt

Now I want rlone to simply exclude the dir1 during sync from tracking any modification either in remote or local. So I use the flag --exclude-if-present .rcignoredir add a file in the tree.

dir1/.rcignoredir

Now during sync, rclone in an attempt to exclude the directory, it deletes the entire dir1 tree in the remote/destination. I expected it not to delete anything from destination, but simply ignore any changes in dir1 on both sides.

I know I can do this with --exclude /dir1 flag, which also works as I expected, i.e ignoring dir1 from sync without deleting anything from remote.

So, I find this behavior inconsistent between --exclude-if-present flag and all other filterings flags (https://rclone.org/filtering/). For other flags, what I understand, rclone will only delete files from remote ONLY if I enable --delete-excluded additionally.

What is your rclone version (output from rclone version)

rclone v1.51.0
- os/arch: linux/amd64
- go version: go1.13.7

Which OS you are using and how many bits (eg Windows 7, 64 bit)

Linux

Which cloud storage system are you using? (eg Google Drive)

Irrespective of any storage. But I am using SFTP for destination and source is a local directory

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone sync  --checksum /local/dir/ remote: --exclude-if-present .rcignoredir

The rclone config contents with secrets removed.

I think it's not needed

A log from the command with the -vv flag

2020/08/21 21:19:16 DEBUG : rclone: Version "v1.51.0" starting with parameters ["rclone" "--config" "rclone.conf" "sync" "-P" "-vv" "--checksum" "./" "remote:" "--exclude" ".rcfilter" "--filter-from" ".rcfilter" "--exclude-if-present" ".rcignoredir" "--exclude" "upload_site.sh"]
2020/08/21 21:19:16 DEBUG : Using RCLONE_CONFIG_PASS password.
2020/08/21 21:19:16 DEBUG : Using config file from "rclone.conf"
2020/08/21 21:19:18 DEBUG : --removed-- to "SSH-2.0-OpenSSH_4.3"
2020-08-21 21:19:19 DEBUG : .rcfilter: Excluded
2020-08-21 21:19:19 DEBUG : dir1: Excluded
2020-08-21 21:19:19 DEBUG : upload_site.sh: Excluded
2020-08-21 21:19:23 DEBUG : .ftpquota: Excluded
--- REMOVED ----
2020-08-21 21:20:07 INFO  : --removed--: Waiting for transfers to finish
2020-08-21 21:20:07 INFO  : Waiting for deletions to finish
2020-08-21 21:20:07 INFO  : dir1/file1.txt: Deleted
2020-08-21 21:20:07 INFO  : dir1/dir2/file2.txt: Deleted
2020-08-21 21:20:07 DEBUG : dir1/dir2: Removing directory
2020-08-21 21:20:09 DEBUG : dir1: Removing directory
2020-08-21 21:20:10 DEBUG : --removed--: deleted 2 directories
Transferred:             0 / 0 Bytes, -, 0 Bytes/s, ETA -
Checks:               367 / 367, 100%
Deleted:                2
Elapsed time:        44.2s
2020/08/21 21:20:10 INFO  :
Transferred:             0 / 0 Bytes, -, 0 Bytes/s, ETA -
Checks:               367 / 367, 100%
Deleted:                2
Elapsed time:        44.2s

2020/08/21 21:20:11 DEBUG : 147 go routines active
2020/08/21 21:20:11 DEBUG : rclone: Version "v1.51.0" finishing with parameters ["rclone" "--config" "rclone.conf" "sync" "-P" "-vv" "--checksum" "./" "remote:" "--exclude" ".rcfilter" "--filter-from" ".rcfilter" "--exclude-if-present" ".rcignoredir" "--exclude" "upload_site.sh"]

Originally reported at https://forum.rclone.org/t/destination-dir-deleted-on-using-exclude-if-present-flag/18654

Activity

  1. ncw commented on Aug 23, 2020

    @ncw
    Member

    I can reproduce this problem

    $ tree src
    src
    └── dir
        └── file1.txt
    
    1 directory, 1 file
    $ tree dst
    dst
    └── dir
        └── file1.txt
    
    1 directory, 1 file
    $ touch src/dir/.exclude
    $ rclone sync -vv --exclude-if-present .exclude src dst
    2020/08/23 18:07:01 DEBUG : rclone: Version "v1.52.3-328-g0f7a2f0f-beta" starting with parameters ["rclone" "sync" "-vv" "--exclude-if-present" ".exclude" "src" "dst"]
    2020/08/23 18:07:01 DEBUG : Using config file from "/home/ncw/.rclone.conf"
    2020/08/23 18:07:01 DEBUG : fs cache: renaming cache item "src" to be canonical "/tmp/src"
    2020/08/23 18:07:01 DEBUG : fs cache: renaming cache item "dst" to be canonical "/tmp/dst"
    2020/08/23 18:07:01 DEBUG : dir: Excluded
    2020/08/23 18:07:01 DEBUG : Local file system at /tmp/dst: Waiting for checks to finish
    2020/08/23 18:07:01 DEBUG : Local file system at /tmp/dst: Waiting for transfers to finish
    2020/08/23 18:07:01 DEBUG : Waiting for deletions to finish
    2020/08/23 18:07:01 INFO  : dir/file1.txt: Deleted
    2020/08/23 18:07:01 DEBUG : dir: Removing directory
    2020/08/23 18:07:01 DEBUG : Local file system at /tmp/dst: deleted 1 directories
    2020/08/23 18:07:01 INFO  : There was nothing to transfer
    2020/08/23 18:07:01 INFO  : 
    Transferred:   	         0 / 0 Bytes, -, 0 Bytes/s, ETA -
    Checks:                 1 / 1, 100%
    Deleted:                1
    Elapsed time:         0.0s
    
    2020/08/23 18:07:01 DEBUG : 3 go routines active
    $ tree dst
    dst
    
    0 directories, 0 files
    

    I agree with you that this behaviour is unexpected - excluding things shouldn't delete them in the destination unless --delete-excluded is set.

    I'm not sure how easy it will be to fix though since the --ignore-if-present flag works by altering the directory listings so removing the directories from the source which means that they get deleted in the destination.

    At very minimum this should be called out in the docs.

  2. added this to the v1.53 milestone on Aug 23, 2020
  3. modified the milestones: v1.53, v1.54 on Sep 5, 2020
  4. modified the milestones: v1.54, v1.55 on Feb 3, 2021
  5. modified the milestones: v1.55, v1.56 on Apr 3, 2021
  6. modified the milestones: v1.56, v1.57 on Jul 20, 2021
  7. modified the milestones: v1.57, Known Problem on Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions