I want to sync my ubuntu 14.04 installation with a directory in an external disk.

Actually I booted up from an expansion drive and I want to make a partial copy of my ubuntu 14.04 distro in the internal drive which I mounted on /media/kenn/c2d1b866/

The destination directory mounted on /mnt/RESTORE/backup_14.04.5

I tried many combinations of rsync command such as

sudo rsync -avr /media/kenn/c2d1b866/{bin/,sbin/,usr/,opt/,lib/,var/,etc/,srv/,libx32/,lib64/,run/,boot/,proc/,sys/,dev/} /mnt/RESTORE/backup_14.04.5

sudo rsync -avr /media/kenn/c2d1b866/{bin/,sbin/,usr/,opt/,lib/,var/,etc/,srv/,libx32/,lib64/,run/,boot/,proc/,sys/,dev/} /mnt/RESTORE/backup_14.04.5/

sudo rsync -avr /media/kenn/c2d1b866/{"bin/","sbin/","usr/","opt/","lib/","var/","etc/","srv/","libx32/","lib64/","run/","boot/","proc/","sys/","dev/"} /mnt/RESTORE/backup_14.04.5

and many other, but I failed, because brace expansion doesn't work as I expected. They copy all files inside brace directories into /mnt/RESTORE/backup_14.04.5 , I mean root directories not created in backup_14.04.5

How can I copy those bin/,sbin/,usr/,opt/,lib/,var/,etc/,srv/,libx32/,lib64/,run/,boot/,proc/,sys/,dev/

in /media/kenn/c2d1b866/ to /mnt/RESTORE/backup_14.04.5 ?

  • You didn't say what happened with your tries. – muru Jan 6 '17 at 17:48

They copy all files inside brace directories into /mnt/RESTORE/backup_14.04.5

That's the rsync behaviour when the source path has a trailing slash /. From man rsync:

A  trailing slash on the source changes this behavior to avoid creating
an additional directory level at the destination.  You can think  of  a
trailing / on a source as meaning "copy the contents of this directory"
as opposed to "copy the directory by  name",  but  in  both  cases  the
attributes   of   the  containing  directory  are  transferred  to  the
containing directory on the destination.

To copy the directories, omit that /:

sudo rsync -avr /media/kenn/c2d1b866/{bin,sbin,usr,opt,lib,var,etc,srv,libx32,lib64,run,boot,proc,sys,dev} /mnt/RESTORE/backup_14.04.5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.