I would like to request information on using rsync. I tried reading reading the manuals, but the examples are few and confusing for me.

I do not need advanced features or live sync or remote sources or remote destinations. Everything is with ext4. Just using my laptop's HDD and an external HDD over USB. On Ubuntu.

My ultimate object is to move the contents of my /home to an external drive. Wipe my laptop, switch it to LVM, re-install Ubuntu, update, install same programs I had before, then boot a live USB and copy the contents of my backed up /home (now on my external HDD) onto the /home of the new installation (installed with same username and uid as last time).

I would like to keep all permissions and ownership the same.

I tried copy-pasting everything onto the external drive, but I got error messages. I know that doing a copy-paste from the GUI on a live USB will change everything to root ownership (which would be double plus ungood).

I see all of these flags in the man page ... and all I understand is rsync /home/jonathan /media/jonathan/external-drive/home/jonathan from rsync /source/file/path /destination/file/path.

I already use this hard drive to back up most folders and big files like Movies, etc. Is there a way to copy-paste what I want, while saving permissions, and only adding the hitherto ignored .config files and only changing changed files? I would like to be able to do this manually about once a week to back up settings AND my personal files in case I ever need to reinstall in an emergency or my hard drive fails.

Thank you for any help

  • Hint: log out of your GUI, and use a Ctrl-Alt-F2 terminal. That will reduce the number of open files. – waltinator Mar 27 at 3:21

The easiest way to do this would be to use a live USB and use the -a flag for rsync.

This flag (I think -a stands for archive) preserves all the file and folder attributes, including permissions.

Once you're in a live session, plug in your external drive and use sudo blkid to see which drives correspond to which devices in /dev. You might find that your live USB is /dev/sda, while your laptop's HDD is /dev/sdb, and perhaps your external drive is /dev/sdc. I'll pretend for the example that those are the drive names but yours may vary.

Make subfolders for your laptop and external drives:

sudo mkdir /mnt/laptop
sudo mkdir /mnt/external

Then mount the drives and create a folder in your external drive if it doesn't exist:

sudo mount /dev/sdb /mnt/laptop
sudo mount /dev/sdc /mnt/external
sudo mkdir /mnt/external/home

Then use rsync to copy the data in archival mode:

sudo rsync -av /mnt/laptop/home/jonathan /mnt/external/home

Make sure you don't use a trailing slash in the origin folder name, so that rsync creates it for you with the right permissions.

Move to the folder in the external drive:

cd /mnt/external/home/jonathan

And check that the file permissions were preserved with ls -la.

Good luck!

| improve this answer | |
  • Thank you. This worked! – Jonathan Joseph Chiarella Apr 26 at 21:37
  • That's great @JonathanJosephChiarella! If so, would you kindly mark the answer as accepted? – Kurankat Apr 27 at 0:11

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.