Skip to content

Standardize with rsync path declarations #383

Closed

Description

@InAnimaTe

As I use rclone more and more, I've noticed the requirement around source directory copying...and frankly, it really should be changed to resemble how rsync actually works.

This means that copy supercooldir hubic_remote:cake should copy the directory supercooldir into the cake bucket, not the contents. However, copy supercooldir/ hubic_remote:cake should actually copy the contents of supercooldir into the cake bucket.

From the rsync man page:

A trailing / on a source name means "copy the contents of this directory". Without a trailing slash it means "copy the directory".

I'm not sure if there's been any discussion on this already so forgive me if this has already been proposed.

Activity

  1. ncw commented on Jul 15, 2016

    @ncw
    Member

    Sorry I missed this ticket!

    Yes there has been some discussion on this.

    I'm of the opinion that rsync's way of doing it, while clever, is extremely error prone and a mis-feature.

    If you type

    rsync -av --delete /path/to/my/files dest:/path/to/backup
    

    Then one say with a bit of command line completion help, type

    rsync -av --delete /path/to/my/files/ dest:/path/to/backup
    

    Then you just deleted all the files in your backup and re-uploaded them :-(

    I made rclone so that the trailing slash is irrelevant like it is in the rest of the unix world and it always refers to the directory contents.

    I did write this in the docs to address this point for new users

    If you are familiar with rsync, rclone always works as if you had
    written a trailing / - meaning "copy the contents of this directory".
    This applies to all commands and whether you are talking about the
    source or destination.

    I think, practically speaking, it is too late to change it, even if I wanted to :-(

  2. added this to the Known Problem milestone on Jul 15, 2016
  3. jody-frankowski commented on Oct 20, 2016

    @jody-frankowski
    Contributor

    I made rclone so that the trailing slash is irrelevant like it is in the rest of the unix world and it always refers to the directory contents.

    Isn't it the exact contrary?
    cp -r directory dest will copy the directory itself, not just its content.

    IMHO it would be better if it was that way in rclone. As for copying only the content of the directory you could either implement rsync's trailing slashway , or the '*' wildcard if you think it is too much error prone (or maybe both).

  4. ncw commented on Nov 3, 2016

    @ncw
    Member

    @jody-frankowski I'm going to fix this with two new commands cp and mv which will work exactly like their unix counterparts unlike copy and move

  5. jody-frankowski commented on Nov 4, 2016

    @jody-frankowski
    Contributor

    @ncw Awesome, thanks.
    But don't you think that from the user point of view it will start to get confusing?
    There would be 5 somewhat similar commands: copy move sync cp mv

    I still think having one (and only one) command named copy or cp that would copy the directory itself, but could copy the files with a * wildcard would be better. At least less confusing for the users.

    Another solution would be having only one command (sync or rsync) that would behave like cp with no flags, like mv with the --remove-source-files flag, and like rsync itself with some additional flags. However imho it would be harder for users that have no knowledge of how rsync works.

  6. 19wolf commented on Jul 9, 2018

    @19wolf
    Contributor

    So I'm having some trouble with this. I'm using a Backblaze bucket "b2:mybucket" and I ran rclone sync /data/Media/Photos/2018/ b2:mybucket and ended up with my bucket containing

    Bucket
    --March
    --April
    --May
    

    instead of

    Bucket
    --2018
    ----March
    ----April
    ----May
    

    How do I make it do what I want, without copying over my whole Photos directory? I'm trying to back up my photos by year from most recent to least recent, so eventually I'll have

    Bucket
    --2010
    ----March
    ----April
    --2011
    ----April
    ----May
    --2012
    ----May
    --2013
    ----etc
    
  7. ncw commented on Jul 10, 2018

    @ncw
    Member

    This should do the trick

    rclone sync /data/Media/Photos/2018 b2:mybucket/2018
    
  8. sedlund commented on Mar 11, 2019

    @sedlund
    Contributor

    what is the equivalent for

    rsync b2:mybucket/data/myfile* .

    in rclone?

    I've tried copy, copyto, sync, --include, --exclude, --filter etc...

    It just seems there are way too many options to do something that should be trivial.

  9. ncw commented on Mar 11, 2019

    @ncw
    Member

    what is the equivalent for

    rsync b2:mybucket/data/myfile* .

    in rclone?

    rclone copy b2:mybucket . --include "myfile*"
    

    Should do it.

  10. sedlund commented on Mar 11, 2019

    @sedlund
    Contributor

    rclone copy b2:mybucket . --include "myfile*"
    Should do it.

    Thanks @ncw this does copy the file, but this also copies all the directories underneath that path without the files.

    rclone v1.46
    - os/arch: linux/amd64
    - go version: go1.11.5
    
    
    --- start filters ---
    --- File filter rules ---
    + (^|/)myfile[^/]*$
    - ^.*$
    --- Directory filter rules ---
    + ^.*$
    - ^.*$
    --- end filters ---
    2019/03/11 17:34:25 NOTICE: myfile_superneat: Not copying as --dry-run
    2019/03/11 17:34:26 NOTICE: blah: Not making directory as dry run is set
    2019/03/11 17:34:26 NOTICE: blah2: Not making directory as dry run is set
    etc...
    
  11. ncw commented on Mar 11, 2019

    @ncw
    Member

    Thanks @ncw this does copy the file, but this also copies all the directories underneath that path without the files.

    You want --include /myfile* then to just copy files in the root - hopefully that will work :-)

  12. animosity022 commented on May 10, 2020

    @animosity022
    Contributor

    @InAnimaTe - Is this still an open item or can it be closed out?

  13. InAnimaTe commented on May 10, 2020

    @InAnimaTe
    Author

    I haven't used rclone in 3 years so probably something that can be closed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions