Search code examples
bashrsync

rsync duplicates files when archiving to another computer when using include-from


Background:

I got a new computer and am trying to use rsync to copy files over to it (Apple's migration assistant repeatedly gets to 16 min left and then hangs forever--I'm trying to work around that problem by using rsync).

Problem:

I'm trying to copy files from my old computer over to my new one. I'm running the following script on my new computer.

# in Dropbox/migrate.sh:
set -x

IP=10.1.1.5
rsync -navzhe ssh --include-from="Dropbox/migration_files.txt" --exclude="*" $IP:.* ~



# in Dropbox/migration_files.txt:
.lein/
.lein/profiles.clj
bmaddy/
bmaddy/4clojure.clj
Desktop**

Expected:

I expect to see something like this:

$ Dropbox/migrate.sh 
++ IP=10.1.1.5
++ rsync -navzhe ssh --include-from=Dropbox/migration_files.txt '--exclude=*' '10.1.1.5:.*' /Users/bmaddy
receiving file list ... done
./
.lein/
.lein/profiles.clj
Desktop/
Desktop/piano.txt
bmaddy/
bmaddy/4clojure.clj

Actual:

What I actually see is this:

$ Dropbox/migrate.sh 
++ IP=10.1.1.5
++ rsync -navzhe ssh --include-from=Dropbox/migration_files.txt '--exclude=*' '10.1.1.5:.*' /Users/bmaddy
receiving file list ... done
./
.lein/
.lein/profiles.clj
Desktop/
Desktop/piano.txt
bmaddy/
bmaddy/4clojure.clj
bmaddy/.lein/
bmaddy/.lein/profiles.clj
bmaddy/Desktop/
bmaddy/Desktop/piano.txt
bmaddy/bmaddy/
bmaddy/bmaddy/4clojure.clj

When I actually run this (without -n), all the files in Desktop, .lein, and bmaddy get duplicated under the bmaddy directory.

Does anyone know why those files would be duplicated and how I could stop that from happening?

$ rsync --version
rsync  version 2.6.9  protocol version 29

Solution

  • Here's the solution I found to eventually get things to work:

    # in Dropbox/migrate.sh
    set -x
    
    IP=10.1.1.5
    
    rsync -navzhe ssh --include-from="Dropbox/migration_files.txt" --exclude="*" $IP:. ~
    
    # in Dropbox/migration_fiels.txt
    /.lein/
    /.lein/profiles.clj
    /bmaddy/
    /bmaddy/4clojure.clj
    /Desktop**