Thursday, December 10, 2009

Tidbit: Migrating Data From One Computer To Another in Linux

There comes a time when a computer user gets a new machine and has to migrate his/her data. This is far from a fun experience. Wouldn't it be nice if you could have all your files and settings transfered to the new machine? I'm sure there are many ways to go about this, but this is the way I did it using rsync.


For clarity's sake, commands run on the old machine will be pink and commands run on the new machine will be blue.


First, I installed rsync and openssh on both machines using the package manager. For openssh you need at least the server on the old machine and the client on the new one.


Ubuntu/Mint: $ sudo aptitude install rsync openssh-server
Ubuntu/Mint: $ sudo aptitude install rsync openssh-client

Arch Linux (as root): # pacman -Sy rsync openssh
Arch Linux (as root): # pacman -Sy rsync openssh


Secondly, you will need to have both your machines on the same network. I have a wireless router at home, so that simplified things having both laptops connect to the local network. However, a 802.11b wireless network plus ~30GB of data makes for a lot of waiting while things are copied over. If you do not have a home network, you could use a crossover cable to connect the two machines together. Basically, make sure the machines can ping each other. You may need to change the firewall settings to allow a connection to the SSH server. Then, start up the Open SSH server on the old one.


Ubuntu/Mint: $ sudo /etc/init.d/ssh restart
Arch Linux (as root): # /etc/rc.d/sshd restart


Thirdly, we will create a folder where we will put all our data and then copy the files over.


Ubuntu/Mint/Arch: $ mkdir ~/<destination folder>
Ubuntu/Mint/Arch: $ rsync -avz --progress <user name on old machine>@<IP address of old machine>:/home/<user name on old machine>/ ~/<destination folder>
E.g. $ rsync -avz --progress shane@192.168.16.100:/home/shane/ ~/from-old-machine


You will be prompted for the password of the user on the old machine. Once it starts, sit back and wait. If the transfer gets interrupted you can resume it later with the same command. If a file has been modified on the old machine after if has been copied over, it will be updated. See the rsync man page for more info. If you want any settings from your old machine e.g. your Firefox plugins, saved passwords and bookmarks, move the ~/from-old-machine/.mozilla folder to ~/.


If you want the entire setup to be transfered over as is, log out from the GUI on the new machine and log in on a virtual terminal (Ctrl+Alt+F1). This will delete all user files and settings on the new machine. Run:


Ubuntu/Mint/Arch: $ rm -rf ~/* ~/.??*
Ubuntu/Mint/Arch: $ rsync -avz --progress shane@192.168.16.100:/home/shane/ ~/


Enjoy your new computer!


[EDIT] I am not sure if this will work, but here is a Google Wave invitation. First come, first serve!

No comments: