0

My install had the /home folder inside /. I wanted to add a separate /home partition, so I created a small backup partition on a different drive, added it to /etc/fstab, and used rsync with -aXS to move my old /home folder to this new partition. I then did a fresh install with a /home partition. Now I would like to move my files back from the old /home folder into the new /home directory. What is the best way to do this?

What I tried: sudo rsync -aXS /home_backup/. /new_home_partition/. as per this guide

This copied the old /home folder itself into the /home partition (i.e. it created /home/home), which is not what I wanted. I figured I could run the same command, but on the subfolders within the backup folder rather than on the folder itself. Is this the best way to go about it?

I saw this similar question, but as I understand it, cp will not preserve information like permissions and links. I also saw this question, but I don't know how to work with tarballs (and I'm not positive the OP's situation is the same). Any help would be appreciated, as I'm by no means an expert!

P.S. What is the best command to remove all files from the fresh /home partition before copying the backup files into it?

Edit: Looks like I was able to resolve this, but I still don't know what happened (added a comment below).

1 Answers1

0

rsync is an appropriate tool to make an identical copy of a directory structure. To preserve permissions with rsync, use the a option. More complete preservation of original properties is obtained with the options -H, -A and -X (see man rsync to see what they do). These are not included in the -a option for performance reasons. You can add them if needed. For example, if you extensively work with hard links, you will want to add the -H option to keep hard linked items in the source as one file in the destination as well.

vanadium
  • 97,564