How can I backup a Ubuntu system and restore it on another maching with completely different hardware?

I just completed my Ubuntu installation. It contains all packages I need and I configured my apps correctly.

I would like to backup this installation and be able to restore it to different computers with different hardware.

I have read that the solution would be the following:

1- Save a list of the installed packages.
2- Backup the home directory.

3- Install the same version of Ubuntu on the new machine.
4- Restore the list of installed packages on the new machine.
5- Restore the backup of the home directory on the new machine.

Would this keep all of my insalled softwares and their configurations?


Solution 1:

That should indeed restore all software and their settings, as they are stored inside your home folder (don't forget to copy the hidden folder, because that's where the configuration files are kept!). The applications that are run as root however, will most probably lose their configuration this way.
Just a little hint to prevent trouble, choose the same username and password on the target machine as you did on the machien where you copied everything from. Choosing the same host name would be a good idea as well, I think.

Solution 2:

I set up machines, customize them a bit and then restore them onto other machines, almost always with different hardware, so here's what I normally do:

NOTE: sometimes I have issues with graphic drivers, (frequently nvidia) when moving to and from a machine that didn't have them or had a different version of them.


FIRST: run most of this as root with sudo (you can lock the command line on root using sudo -s )


Backup
1. boot the source machine with a live CD
2. plug in a storage device large enough to hold a snapshot of the machine.
3. backup everything to the external hard drive using tar command.
     for example:     tar cvpzf /media/BackupDrive/SystemBackup.tar.gz ./


Restore
1. boot the destination machine from a live CD
2. use the partitioning tool (gparted) to create the ext4 and swap partition
3. untar the backup onto the recently created partition.
     for example:     tar xvpzf /media/BackupDrive/SystemBackup.tar.gz ./


Fix Grub and boot sector
I usually use the boot-repair-disk for this https://sourceforge.net/projects/boot-repair-cd/

  • if the machines are going to live in the same network you might want to change it's name (edit /etc/hostname )

  • you may also want to update /etc/fstab with the proper hard drive ID's for this run the command blkid and get the UUID string for each partition and then use your favorite text editor to replace it in your respective fstab file line