No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-17 11:51:24 -05:00
README.md initial commit 2026-10-17 11:51:24 -05:00
system-backup.service initial commit 2026-10-17 11:51:24 -05:00
system-backup.sh initial commit 2026-10-17 11:51:24 -05:00
system-backup.timer initial commit 2026-10-17 11:51:24 -05:00

Arch System Backup: Setup & Restore Guide

Oct 17, 2026 · @Someone

Overview

A daily systemd timer copies your whole root filesystem to the cold storage drive as a dated snapshot, and keeps the newest 5. You can also run it by hand at any time, for example right before trying a new WM.

Each snapshot is a complete, browsable copy of /. Unchanged files are hard-linked to the previous snapshot, so only the first snapshot takes full space; later ones only take space for what changed. Because older snapshots are kept, a broken system that gets backed up by the timer never overwrites your last good state.

If the drive is unplugged when the timer fires, the run is skipped quietly. If the drive is plugged in but not mounted, the script mounts it and unmounts it again afterwards.

File Installed to Purpose
system-backup.sh /usr/local/bin/system-backup The backup script
system-backup.service /etc/systemd/system/ Runs the script at low CPU and disk priority
system-backup.timer /etc/systemd/system/ Triggers the service daily, or at next boot if a run was missed

On the backup drive, snapshots are laid out like this:

snapshots/
├── 2026-10-15_031204/
├── 2026-10-16_030851/
├── 2026-10-17_032417/
└── latest -> 2026-10-17_032417

Setup

Setup takes about five minutes plus the first backup. The backup drive must use ext4 or another Linux filesystem; the script refuses NTFS, exFAT and FAT because they can't store Linux permissions.

  1. Find the backup drive's UUID. With the drive plugged in, run:

    lsblk -f
    

    Copy the UUID of the backup partition (for example sdb1), not the whole disk. Check the FSTYPE column says ext4.

  2. Edit the script's configuration. Open system-backup.sh and set the values at the top:

    BACKUP_UUID="your-uuid-here"
    FALLBACK_MOUNT="/mnt/backup"   # used only if the drive isn't already mounted
    SNAPSHOT_DIR="snapshots"
    KEEP=5
    

    To save space, you can uncomment entries in EXTRA_EXCLUDES, such as /home/*/.cache/*.

  3. Install the three files. From the folder containing them:

    sudo install -Dm755 system-backup.sh /usr/local/bin/system-backup
    sudo install -Dm644 system-backup.service /etc/systemd/system/system-backup.service
    sudo install -Dm644 system-backup.timer /etc/systemd/system/system-backup.timer
    
  4. Enable the timer.

    sudo systemctl daemon-reload
    sudo systemctl enable --now system-backup.timer
    
  5. Optional: reuse your earlier manual backup. If you already have a full copy in arch-snapshot, turn it into the first snapshot so the next run only copies changes:

    cd /path/to/backup
    sudo mkdir -p snapshots
    sudo mv arch-snapshot snapshots/2026-10-17_000000
    sudo ln -s 2026-10-17_000000 snapshots/latest
    
  6. Run the first backup by hand and watch it finish:

    sudo system-backup
    

    The first run copies everything and can take a while. It ends with snapshot <date> complete.

  7. Confirm the timer is scheduled:

    systemctl list-timers system-backup.timer
    

Everyday use

Once set up, backups run on their own whenever the drive is connected. Take a manual snapshot before any risky change, so you have a known-good point from minutes ago rather than from last night.

Task Command
Back up now, with a progress bar sudo system-backup
Back up now, through systemd sudo systemctl start system-backup.service
See when the next run is systemctl list-timers system-backup.timer
Read logs of past runs journalctl -u system-backup
List your snapshots ls -l /path/to/backup/snapshots/
Pause automatic backups sudo systemctl stop system-backup.timer
Resume automatic backups sudo systemctl start system-backup.timer

If you change the script later, reinstall it with the same install command from Setup step 3. If you change the .service or .timer files, also run sudo systemctl daemon-reload.

Restoring the full system

A full restore copies a snapshot back over your OS drive from an Arch live USB, returning the system exactly to that point. Anything created after the snapshot, including files in /home, is removed, so copy out any new files you want to keep first (see the next section).

You need an Arch install USB. The live environment already includes rsync.

  1. Boot the Arch USB and get to the root prompt.

  2. Identify your partitions:

    lsblk -f
    

    Note your root partition, any separate /boot (EFI) or /home partitions, and the backup drive.

  3. Mount your system the way it's normally laid out, with root first. Replace the device names with yours:

    mount /dev/nvme0n1p2 /mnt          # root
    mount /dev/nvme0n1p1 /mnt/boot     # only if /boot is a separate partition
    mount /dev/nvme0n1p3 /mnt/home     # only if /home is a separate partition
    
  4. Mount the backup drive somewhere outside /mnt:

    mkdir /backup
    mount /dev/sdX1 /backup
    ls -l /backup/snapshots/
    

    Pick the snapshot to restore. latest is the newest; choose an older dated folder if the newest was taken after things broke.

  5. Do a dry run first. The -n flag shows what would change without touching anything:

    rsync -aAXHn --numeric-ids --delete --info=progress2 \
      --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/boot/*"} \
      /backup/snapshots/2026-10-17_032417/ /mnt/
    

    Check that the destination is /mnt/ and the trailing slashes are present on both paths.

  6. Run the real restore by repeating the command without n:

    rsync -aAXH --numeric-ids --delete --info=progress2 \
      --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/boot/*"} \
      /backup/snapshots/2026-10-17_032417/ /mnt/
    
  7. Restore /boot separately. The EFI partition is usually FAT, which can't take Linux ownership or ACLs, so it gets simpler options:

    rsync -rtv --delete --modify-window=1 \
      /backup/snapshots/2026-10-17_032417/boot/ /mnt/boot/
    

    If /boot is on your ext4 root rather than its own partition, you can instead drop "/boot/*" from the exclude list in steps 5 and 6 and skip this step.

  8. Unmount and reboot:

    sync
    umount -R /mnt
    umount /backup
    reboot
    

Restoring onto the same partitions keeps their UUIDs, so /etc/fstab and your bootloader config still match and nothing else needs changing. If you reformatted a partition or are restoring to a new drive, the UUIDs will differ: update /mnt/etc/fstab with the new values from lsblk -f, then arch-chroot /mnt and reinstall or reconfigure your bootloader before rebooting.

Restoring individual files, and troubleshooting

For small breakage, such as a bad config file, you don't need a full restore. Snapshots are ordinary folders, so you can copy single files or directories back from the running system:

# one file
sudo cp -a /path/to/backup/snapshots/latest/etc/pacman.conf /etc/pacman.conf

# your whole ~/.config as it was
rsync -aAX --delete /path/to/backup/snapshots/latest/home/you/.config/ ~/.config/

To see what a WM install changed, compare a snapshot with the live system using diff -r, or check /var/log/pacman.log for the packages installed since the snapshot's date.

Message or symptom Cause and fix
set BACKUP_UUID ... first The UUID still says CHANGE-ME. Edit /usr/local/bin/system-backup.
backup drive not connected; skipping The drive is unplugged, or the UUID is wrong. Compare against lsblk -f.
backup drive is ntfs/exfat/vfat The drive needs a Linux filesystem such as ext4.
another backup is already running A timer run is in progress. Wait for it, or check systemctl status system-backup.service.
rsync failed with exit code 11 or 12 Usually the backup drive is full. Lower KEEP, add EXTRA_EXCLUDES, or use a bigger drive.
Some files reported as vanished Normal on a running system; the snapshot is still complete.
System won't boot after a restore Boot the USB, mount as in the restore steps, arch-chroot /mnt, then check /etc/fstab UUIDs and run mkinitcpio -P.