Transfer home directory to another machine with settings intact

Q I've installed Mandriva 2008 on my new machine and the network is working so I can see the Home directory on the old machine. I now want to transfer everything to the new machine, including hidden files and config files. I'm wondering about the best way to do this. Should I back up the /home directory and reinstate it on the new machine? Or just copy files over, which may take some time?

A If networking is up and you have the SSH service running on the old computer, the best way to do this is with rsync. Open a terminal on the new computer, as your normal user, and run:

rsync -ax olduser@oldmachine:~/ ~/

The trailing slashes are important. If the username is the same on both computers, you can omit the olduser@ part. This will copy everything in your home directory, including hidden files, and set all permissions and timestamps correctly. Even if you use different usernames, or the same usernames with different numeric IDs, rsync user after copying. You shouldn't be logged in on the old computer when doing this, as there's the possibility that some files may be changed between the initial directory scan and the copying, which would cause rsync to exit with an error. If you have a desktop running on the old computer, close it down before running rsync. Copying everything verbatim may not be a good idea, because you may overwrite newer config files with older versions. An alternative is to create a directory in your home and copy to that, with:

mkdir ~/oldhome
rsync -ax olduser@oldmachine:~/ ~/oldhome

Then you can use your favourite file manager to copy over the files and directories you need and delete the older config files and the general cruft we all accumulate in our home directories over time. This is one of those jobs that's quicker to do from the command line, but if you prefer to use a GUI, there are alternatives. If you use KDE, the default desktop on Mandriva, open a Konqueror window, select one of the Window > Split View options, use one pane to create and show the oldhome directory and type fish://olduser@oldmachine into the location bar for the other pane. This should display olduser's home directory, from which you can select and copy files and directories. Select View >Show Hidden Files to display all your configuration files, then press Ctrl+A to select everything, followed by F7 to copy it. Midnight Commander is another file manager that can use the FISH protocol to access files on a remote computer. If you regularly need to synchronise directories on two computers, I strongly recommend Unison (www.cis.upenn.edu/~bcpierce/unison), which I use to keep my desktop and laptop in sync, but it's overkill for a one-off copy.

Follow us on Identi.ca or Twitter

Username:   Password:
Create Account | About TuxRadar