User:Gen2ly/System backup and reinstall
This tutorial is to explain how to backup the system configurations and other likewise items in order to expedite a reinstall process.
The justification for this tutorial generally is:
- The system architecture is desired to be changed (e.g. 32-bit to 64-bit)
- A system problem has occurred and troubleshooting has failed (external help from the wiki or forums is unavailable)
The discouragement for this tutorial is:
- The system installation that is extremely outdated. Because package and configurations change over time this method may be ineffectual and possibly even harmful (in terms of dataloss). For installations older than six months (and sometimes even less) consider reinstalling from the onset according to the Installation guide.
A few things to know about this tutorial before reading:
- A backup destination has been throughout defined:
- The system installation is recommended to be updated and configurations merged (if doable). This will keep backup configurations equivocal with their reinstalled counterparts.
- The backup is recommended to be saved on a separate storage disk. This will ease the process of the backup.
The backup process will involve these steps:
- Backup system configurations
- Record the package list(s)
- Backup the package tarballs
A typical method to do multi-file backups is to create a list of the required files.
rsync both have the ability to define a file-list in an include and an exclude file. The format to use is one file per line with the full path. For example:
include.txt /etc/fstab /etc/modules-load.d/ /etc/pacman.conf ...
exclude.txt # only testing /etc/modules-load.d/loop*
To create a backup from the file-list, with
rsync respectively do:
tar --create --xz --files-from=include.txt --exclude-from=exclude.txt --file /mnt/backup/amiga_$(date +%F)_syscfg.tar.xz rsync --archive --files-from=include.txt --exclude-from=exclude.txt / /mnt/backup/amiga_$(date +%F)_syscfg/
(The include file must list valid files or the programs will exit with an error. However, the exclude file does not have to list valid files because it allows glob pattern matches.)
rsync command defines the source directory as the root directory (
/), this is necessary to coincide with the full path specified in the file listing.)
A listing can be created of installed packages of both official repository packages and local packages. These lists can be used upon the reinstall to define the package selection.
To create a list of all official repository installed packages do:
$ pacman -Qqe | grep -v "$(pacman -Qqm)" > /mnt/backup/amiga_$(date +%F)_pkglist-off.txt
To create a list of all local installed packages do (includes packages installed from the AUR):
$ pacman -Qqm > /mnt/backup/amiga_$(date +%F)_pkglist-loc.txt
By creating a backup of package tarballs that have been previously downloaded time can be saved. During a reinstall a package cache can be defined to the package manager of the previous package tarballs.
To remove package tarballs that are uninstalled or older versions do:
# pacman -Sc
To backup package tarballs:
# cp /var/cache/pacman/pkg/* /mnt/backup/amiga_$(date +%F)_pkg/
The reinstall process will involve these steps:
- Install the base system
- Generate a locale
- Install previous packages
- Restore previous configurations
Install the base system normally as directed in the Installation guide except without editing the configurations.
Generating a locale will be the one exception where editing a configuration will be necessary (a few packages use scripts to install certain features that require a locale be present). Read Locale to learn more.
To reinstall packages from the official repositories (using the backup package cache and the package list):
pacman --needed --cachedir /mnt/backup/amiga_$(date +%F)_pkg/ -S - < /mnt/backup/amiga_$(date +%F)_pkglist-off.txt
To reinstall packages that are local will depend on the method or program that was originally used. If the package tarballs exist for them and they are in the same cache, the above command can be used with the
...pkglist-loc.txt file. If the packages do not have a package tarball and are AUR packages, use a AUR Helper to reinstall them:
AURHELPER ... < /mnt/backup/amiga_$(date +%F)_pkglist-off.txt
When all the packages have been installed the configurations can be restored with
tar --extract --verbose --file /mnt/backup/amiga_$(date +%F)_syscfg.tar.xz -C /mnt/install rsync --archive /mnt/backup/amiga_$(date +%F)_syscfg/ /mnt/install/
- Installation guide procedures should still be observed and keep in mind that they change temporally.
- Partition layout changes will need to be attention paid to. If device designation has changed
/etc/fstab, bootloader configuration will need to be updated.
- Non-default options for the kernel ram disk will require the rebuilding if it before rebooting.
- Edits in the kernel ram disk configuration will necessitate its rebuilding before rebooting.