I'm preparing now to move my Ubuntu 16.04 installation to a new laptop. This is the script I'll be using to backup:
# NAME: full-backup
# PATH: /usr/local/bin
# DESC: Full system backup - must call with SUDO
# DATE: July 16, 2017. Modified Oct 17, 2017.
apt autoclean # reduces size of /var/cache/apt/archives
cd /tmp # tar must be created in directory not backed up.
time tar -cvpzf backup.tar.gz \
Some of my scripts will have to be changed after restoring. For example I have a wrapper script for
dd that ensures data isn't written to
/dev/sdc. The new laptop has PCIe NVMe SSD where the linux naming convention is
/dev/nvme0n1. After restoring I'll make this wrapper script non-executable so it doesn't run and the original
dd runs instead.
Another example is a script that resets the network adapter when resuming from suspend. The new laptop will likely have a different network driver. After restoration I'll comment out loading the old driver names and let the machine suspend/resume without modifications.
Linux headers, which are needed by DKMS to compile custom drivers, are not included in the backup. I will likely remove all DKMS from the new laptop then install it later if a custom driver needed.
Finally before restoring the drive table
/etc/fstab needs to be saved and then copied back after restore.
The compressed backup file size is 6 GB including all
/home files which include not only scripts, data and documents but also configuration files for all applications.