-1

Say I want to back up the "apps" (software, but I guess everything is software) of my system. Some of them are in /opt, some are in my home folder, but where do most go? For those installed via repositories, binaries are in /usr/bin and I hope all other necessary files are in the /usr folder (e.g. libraries and other files)

So, my question is:

If I back up my /usr folder, reinstall the system and restore that folder, will I get all my old apps working? Or do I have to do something else?

1

Not really.

As you said you are going to get all the executables and most of the libraries, but you're going to miss all the configuration files, among other things, so the majority of apps aren't going to run.

If I where thinking something like this, I woould rather prefer to backup the configuration and reinstall the apps. Most of the configuration system files are located under the /etc directory (user config files can be found at $HOME, in hidden files and directories (.file).

  • So backup /usr + /etc? – Dan Oct 17 '17 at 10:29
  • No. Make a list of installed software, and backup the list. Back up configuration files and /home. Don't bother about binaries. If it's hard to get SW - back up the installers. – vidarlo Oct 17 '17 at 10:33
1

If you want a backup so that you can restore a system configuration after a reinstall.
The best way is to create a list of installed programs.

apt-clone provides this functionality. It create a list of currently installed packages that can be used to create the exact same installation on another machine or fresh install.

sudo apt-get install apt-clone
sudo apt-clone clone foo  #This creates a file foo.apt-clone.tar.gz.

Copy it to the destination machine, and run

sudo apt-clone restore foo.apt-clone.tar.gz #this tells apt to install the packages n the list.
0

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:

#!/bin/bash

# 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 \
--exclude=/backup.tar.gz \
--exclude=/proc \
--exclude=/tmp \
--exclude=/mnt \
--exclude=/dev \
--exclude=/sys \
--exclude=/media \
--exclude=/usr/src/linux-headers* \
--exclude=/home/rick/.cache \
--exclude=/var/log \
--exclude=/var/run/ \
--exclude=/run

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/sda, /dev/sdbor /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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.