Skip to content

[Feature request] sync --abort-if / --max-deletes #1032

Open

Description

@ajkis

--abort-if NUM

--abort-if 0
If there are no files present in source do not delete files in dest.

--abort-if 10
If there are less then 10 files in source do not delete files in dest.

rsync
max-delete=NUM
This tells rsync not to delete more than NUM files or directo‐
ries. If that limit is exceeded, all further deletions are
skipped through the end of the transfer. At the end, rsync out‐
puts a warning (including a count of the skipped deletions) and
exits with an error code of 25 (unless some more important error
condition also occurred).

          Beginning  with version 3.0.0, you may specify --max-delete=0 to
          be warned about any extraneous files in the destination  without
          removing any of them.  Older clients interpreted this as "unlim‐
          ited", so if you don’t know what version the client is, you  can
          use  the  less  obvious --max-delete=-1 as a backward-compatible
          way to specify that no deletions be allowed (though  really  old
          versions didn’t warn when the limit was exceeded).

Forum discussion

Activity

  1. added this to the v1.37 milestone on Mar 4, 2017
  2. modified the milestones: v1.37, v1.38 on Jul 19, 2017
  3. modified the milestones: v1.38, v1.39 on Sep 30, 2017
  4. modified the milestones: v1.39, v1.40 on Jan 11, 2018
  5. modified the milestones: v1.40, v1.41 on Mar 19, 2018
  6. modified the milestones: v1.41, v1.42 on Apr 28, 2018
  7. self-assigned this
    on May 6, 2018
  8. 7 remaining items

  9. craig-miskell-fluxfederation commented on Aug 23, 2018

    @craig-miskell-fluxfederation
    Contributor

    Or is #952 relevant (use copy, not sync)?

  10. ishuah commented on Aug 24, 2018

    @ishuah
    Collaborator

    @craig-miskell-fluxfederation I see your point and as you noted, #952 (use copy instead of sync) is the best approach when you don't want your source files deleted.

  11. wlerin commented on Aug 25, 2018

    @wlerin

    @ishuah @craig-miskell-fluxfederation It's not relevant for my specific use case, though if you don't need to track renamed files between source and destination then yes, copy works fine.

    I have a lot more files and data on the cloud than I can store locally, but it is much easier to batch rename (or move) local files and then "sync" those changes with the cloud.

  12. modified the milestones: v1.43, Soon on Sep 2, 2018
  13. olfway commented on Jul 12, 2021

    @olfway

    I have a lot more files and data on the cloud than I can store locally, but it is much easier to batch rename (or move) local files and then "sync" those changes with the cloud.

    I have a similar use case
    Right now I use "sync --max-delete=0" but it ends with an errors, which looks confusing

    2021-07-12 17:53:12 ERROR : Got fatal error on delete: --max-delete threshold reached
    2021-07-12 17:53:12 ERROR : Cancelling sync due to fatal error: failed to delete 1 files
    2021-07-12 17:53:12 ERROR : S3 bucket some-bucket: not deleting directories as there were IO errors
    2021-07-12 17:53:12 ERROR : Fatal error received - not attempting retries
    Transferred:   	         0 / 0 Bytes, -, 0 Bytes/s, ETA -
    Errors:                 2 (fatal error encountered)
    Checks:                31 / 31, 100%
    Deleted:                1 (files), 0 (dirs)
    Elapsed time:        29.9s
    2021/07/12 17:53:12 Failed to sync with 2 errors: last error was: failed to delete 1 files
    

    I would prefer to add --delete-never to tell rclone just sync local files and do not try to delete

  14. Masamune3210 commented on Jul 12, 2021

    @Masamune3210
    Contributor

    correct me if im misunderstanding, but a sync without deletes is just a copy right?

  15. wlerin commented on Jul 12, 2021

    @wlerin

    No. As already several times mentioned above, --track-renames only works with sync.

  16. tooptoop4 commented on May 22, 2023

    @tooptoop4

    this is important! i have found s3 copy between 2 buckets ends up doing server side copy and ALWAYS re-copies even though files were already same

  17. asantoni commented on Jun 6, 2023

    @asantoni

    Just to warn anyone who read what @ishuah and @Masamune3210 mentioned - rclone copy can currently delete files, so be forewarned: #6142

  18. Masamune3210 commented on Jun 6, 2023

    @Masamune3210
    Contributor

    It only deletes files on the target due to a bug with detecting failed copies in an attempt to avoid leaving partial corrupted copies of files on some backends in certain circumstances, but the warning is still appreciated

  19. ncw commented on Jun 7, 2023

    @ncw
    Member

    v1.63 will no longer delete files on copy @asantoni @Masamune3210 - by default it will download to a .partial file and rename it if it is correct after the transfer.

  20. Masamune3210 commented on Jun 7, 2023

    @Masamune3210
    Contributor

    Sweeeeeeeeet. I've been bit by that little grub before so it's nice to know it's no longer a issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions