Skip to content

Highly destructive actions require confirmation #1574

Closed

Description

@lucasgonze

#1573 See https://forum.rclone.org/t/unexpected-deletions-in-gdrive/3421 for user-level discussion. This issue is about rclone itself.

A new user just getting to know rclone may naturally explore the sync command. A typical such user will try out the arguments, using trial and error until they are just right.

For example, they may do this:
rclone sync to from

And of course that won't work. The order of the arguments is:
rclone sync from to

However, there is no second chance. The first command will have wiped out the "from" directory.

  • The deletion is permanent. There is no undo or trash can.
  • The deletion is recursive. If you are looking to sync from the root of your remote directory, everything is gone.
  • The deletion is massive. Thousands or tens of thousands of files can disappear.
  • The deletion includes git history, so no restore will be possible.

Suggested fix:

  1. A prompt should ask the user to confirm they want to delete the target permanently
  2. A -f flag should suppress the prompt
  3. Consider an undo feature

Activity

  1. lucasgonze commented on Aug 2, 2017

    @lucasgonze
    Author

    Let me also add a personal note. Your code is incredibly irresponsible. Are you actually not aware that extreme data destruction requires at least a trivial amount of caution?

    In my own case, every source directory for multiple projects, including git history, disappeared. There is no Google Drive feature to get it back. Permanent deletion is the API call used in rclone. You might as well have arranged to smash the drive with a hammer.

    Does rclone create any kind of log, at least? Is there a record of the remote URLs nuked?

  2. lucasgonze commented on Aug 2, 2017

    @lucasgonze
    Author

    To roll back deletions you have to be an enterprise customer. I started up a trial subscription. However the restore feature has not worked. It is possible that if I can get a URL to one of the deleted items it would help. That's why ask I ask about a log.

  3. ncw commented on Aug 2, 2017

    @ncw
    Member

    @lucasgonze I'm very sorry to hear about your problems with rclone.

    The sync command is dangerous - note the bold important in the docs

    Important: Since this can cause data loss, test first with the --dry-run flag to see exactly what would be copied and deleted.

    rsync which rclone is modeled on has the same behavior and rsync is the reason rclone works like it does.

    Consider an undo feature

    rclone has several features which can help here, one of which is --backup-dir which stores any deleted files in a directory of your choice.

    There is also a --drive-use-trash feature which stores deleted items in the trash.

    I don't think either of those would have helped in your case though.

    When you did

    rclone sync to from

    Was to empty at that point? I could put in a test for that.

  4. if1mad commented on Aug 2, 2017

    @if1mad

    @ncw what are your thoughts on having --drive-use-trash as default for sync commands? Or using it as default for any rclone command that has the capability to delete files, e.g move, sync.

    I think having a trash bin on google drive and not using it is such a shame - it's a great safety net that comes at no cost to the user, as storage is unlimited.

  5. if1mad commented on Aug 2, 2017

    @if1mad

    The reason for using drive trash is to be a safety net. Lots of cloud services are unlimited so this is not a problem. If people are limited, they could easily turn off trash.

  6. lucasgonze commented on Aug 2, 2017

    @lucasgonze
    Author

    Compare the downside of not using drive trash to the downside of using it.

    Downside of using it by default: user has to empty trash sooner than expected

    Downside of not using by default: massive accidental irrevocable data loss for newbies

  7. if1mad commented on Aug 3, 2017

    @if1mad

    Downside of using it by default: user has to empty trash sooner than expected

    No. The trash is unlimited, just like your google drive.

    There is literally no downside to using the trash as default that I can think of.

  8. lucasgonze commented on Aug 3, 2017

    @lucasgonze
    Author

    If Trash is not unlimited, the user can either empty it or can set the flag to not use it. Either way this is not a big problem compared to accidental permanent deletion.

  9. 19 remaining items

  10. ncw commented on Jun 10, 2020

    @ncw
    Member

    I've merged the -i PR which I think is a good first step...

  11. ivandeex commented on Nov 15, 2020

    @ivandeex
    Member

    This will can be partially mitigated by config profiles (#2697).
    See #1574 (comment)

  12. ivandeex commented on Dec 23, 2020

    @ivandeex
    Member

    @ncw
    Request for comments:

    In addition to single --interactive flag introduce a multi-variant flag (a concrete name is TBD): --confirmation. Possible states:

    • off (false) or batch - destructive operations proceed automatically
    • on (true) or interactive - destructive operations require y/n on terminal, or abort if stdin is not a tty
    • auto - same as on if stdin is tty, off otherwise

    Then we can:

    • make auto the default
    • make --interactive a shortcut for --confirmation on
    • introduce flag --batch or --force for use in rclone shell wrappers and pipelines (a shortcut for --confirmation off)
    • optionally: interactive mode will fallback to --dry-run instead of just aborting, if stdin is not a tty or when user answered no (or add a new confirmation variant for that)
    • multi-variance allows to add delete or dry-run-specific variants later, but I don't like it, it's complex and confusing IMO
    • optionally: when install.sh finds no existing rclone.conf, create a brand new one with profile section
    [:default]
    confirmations=on
    

    Does this strike balance between batch and interactive usage?
    Is forum or new issue a better place to discuss the idea?
    What do you think?

  13. mrsilva commented on Jan 5, 2021

    @mrsilva

    I can't understand some of the unfortunate comments above, rclone is well documented and it will do what you tell it to do.

    Having said that I do believe rclone could be improved with a 'delete all' protection flag. Something like:

    --delete-protection

    Which when used together with the sync command would only protect destination files from total destruction:

    IF source root folder doesn't exist OR is empty, DON'T touch destination files

    Thanks

  14. ivandeex commented on Nov 19, 2021

    @ivandeex
    Member

    Closed after 1 year of total inactivity.

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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions