5

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?

aviau
  • 143
  • 1
  • 2
  • 9

3 Answers3

4

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

Mikesco3
  • 51
  • 6
  • That sounds so great!! I will try it! Just tired off having to install not only the OS but also all the applications every time I buy a new computer. However, just curious why that works because if the hardware is dissimilar there must be a lot of problems, e.g., many drivers (you said only video, how can it be?). Also most of the parameters in the system files should also be wrong. But you said only need to get new UUID. Isn't that too good to be true? – velut luna Dec 23 '19 at 08:28
  • What is the difference of your method and making an image of the disk by using clonezilla? – velut luna Dec 24 '19 at 02:06
  • @velutluna Clonezilla vs tar.gz backup. with Clonezilla you are packing everything into an image that has not just the files, but also filesystem (ext4, xfs, etc) the boot sector info, disk / partition geometry and stuff like that. One drawback is that it can be tricky to restore a Clonezilla image to a smaller hard drive and it is not as easy to pull out individual data from the backup without restoring it to another disk. – Mikesco3 Jul 16 '22 at 17:28
  • @velutluna The tar.gz file is more like a zip folder of all of the files in your hard drive. (it doesn't contain partition layout info or boot sector details) so it can be just "unzipped" to another folder to just pull out individual files if you want to or restored to a hard drive regardless of the file-system format (ext4, zfs, btrfs, xfs), the disadvantage is that you have to rebuild the boot information after restoring. – Mikesco3 Jul 16 '22 at 17:35
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.

RobinJ
  • 960
  • 5
  • 12
  • Could you explain me how to copy and restore the home folder with the hidden folder? – aviau Nov 08 '11 at 18:35
  • Just press CTRL+H in the file manager to see hidden folders, they're the ones starting with a `.`. – RobinJ Nov 08 '11 at 18:41
  • You may want to grab a copy of the /etc directory as well since that is where most of the system configurations go(firewall, apache, package repositories, etc.) /etc is also fairly small so it won't take up much space. – chuck Nov 08 '11 at 19:03
0

I've successfully used Timeshift in rsync mode to transfer a system to another machine.


On your old System you can:
  1. boot into a live CD (for ex LinuxMint),
  2. plug in an external hard drive, and
  3. run a Timeshift backup in rsync mode pointing it to the external hard drive
    (you may have to format the external hard drive to ext4).

Then on the new computer

  1. boot with the live CD,
  2. plug in an external hard drive, and
  3. use Timeshift to restore the backup from the external hard drive to the new computer.

NOTE 0: You may need to format an external hard drive or large enough usb stick with EXT4 or a linux rsync compatible filesystem.


NOTE 1: if you are backing up / restoring a BTRFS system, still use timeshift in rsync mode
(the btrfs mode of timeshift only takes and restores snapshots into from/to within the same drive/partition)


NOTE 2: if you are backing up / restoring a BTRFS system with multiple subvolumes,
you may have to at least first create:
@ (the root subvolume)
@home (the home subvolume)
this issue may have been fixed already




Mikesco3
  • 51
  • 6
  • **Important**: timeshift by default **does not** copy user data, just system files. Your home folder *will not* be backed up by timeshift, which only makes snapshots of config and system files (more info on their [github](https://github.com/linuxmint/timeshift)) – flen May 17 '23 at 09:14
  • Good comment... however when configuring timeshift, you can tell it to include the `/home` folder. – Mikesco3 Jul 19 '23 at 21:12