Skip to content
XADE edited this page Jul 4, 2024 · 2 revisions

WARNING: must be avoided on immutable distro

How to backup the whole system ?

The script installs the distributions in a way making it easier to

  • backup
    • as we will be backing up the whole root volume including kernel i.e /boot
    • only directory excluded will be /fat i.e. the mount point of Fat partition
    • backing up subvolumes created by user, other other than root i.e. / is out of scope for this page
  • boot into backups

Backup and Upgrade

considering btrfs-progs and gawk is already installed, save the below script somewhere.

#!/bin/sh

# unmount everything from /mnt
umount -Rl /mnt

# store the root device as BLK
BLK=$(mount | awk '/ \/ / {printf $1}')

# store the name of root subvol as VOL
VOL=$(mount | awk -F 'subvol=/|)' '/ \/ / {printf $2}')

# mount root device on /mnt
mount "$BLK" /mnt

# delete the previous snapshot
btrfs subvol delete /mnt/snap_"$VOL"

# create snapshot of current system
btrfs subvol snapshot /mnt/"$VOL" /mnt/snap_"$VOL"

# upgrade the system
pacman -Syu                            # For pacman
xbps-install -Syu                       # For xbps
apk --update-cache upgrade    # For apk-tools
kiss update                               # For kiss
kiss Upgrade
emaint --auto sync                   # For portage
emerge --update --deep --newuse @world

# update GRUB menu
grub-mkconfig -o /boot/grub/grub.cfg

simply run the above script to to backup and upgrade the system. One may also set an alias for the above task.

Boot into backups

The following is only needed to be done once

Considering the installation was named name_of_installation (during installation)

  1. open /fat/grub/grub.cfg with an editor
  2. create a duplicate entry of menuentry name_of_installation {} below it
  3. in that duplicate entry replace name_of_installation with snap_name_of_installation

when booting up next time, GRUB will show an extra entry for snap_my_installtion which can be choosen to boot into backups.

Features

Requirements

Notes


Walk Through :

  1. Execute the script

  1. Select Distro & Packages

Click one of the Distros below for Detailed steps

Distro non Systemd Immutable musl support compilation support
Arch
Artix
Alpine
Void
Gentoo
Funtoo
NixOS
GUIX

Questions :

How ?

Why ?

Clone this wiki locally