BTRFS + Timeshift: express rollback after a broken update

Arch Linux rolling release can break. With BTRFS and Timeshift, you can roll back in minutes. Here is how to automate snapshots and restore your system.

BTRFS + Timeshift: express rollback after a broken update
693 words

Arch Linux is a rolling release distribution: updates arrive fast, but they can sometimes break the system. Instead of praying that pacman -Syu goes well, let’s automate BTRFS snapshots before each update, with express restoration if something goes wrong.

This article follows the Arch Linux installation guide and the post-install guide where Timeshift was already mentioned. Here, we go further: automation and rollback testing.

Prerequisites#

  • An Arch Linux system with BTRFS as the root filesystem (as in the installation article )
  • The btrfs-progs package installed (included in the recommended pacstrap)
  • Timeshift installed: pacman -S timeshift

Configuring Timeshift with BTRFS#

Timeshift supports two modes: rsync (file copy) and btrfs (native snapshots). BTRFS mode is instant and consumes almost no space initially (copy-on-write).

Launch Timeshift and select BTRFS mode:

bash
sudo timeshift-gtk

In the setup wizard:

  1. Select snapshot type BTRFS
  2. Choose snapshot levels:
    • Daily: 1 snapshot per day, keep for 7 days
    • Weekly: 1 snapshot per week, keep for 4 weeks
    • On boot: 1 snapshot at each boot
  3. Exclude large directories if needed (e.g., /opt/data can be excluded if you store large files which don’t need to be restored)

Automating snapshots before updates#

Timeshift handles scheduled snapshots, but the most critical moment is right before an update. Let’s create a pacman hook to trigger a snapshot automatically.

Creating a PreTransaction pacman hook#

Pacman hooks execute at specific points in the update cycle. PreTransaction runs before pacman modifies anything.

Create /etc/pacman.d/hooks/timeshift-autosnap.hook:

ini
[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Path
Target = usr/lib/modules/*/vmlinuz

[Action]
Description = Creating Timeshift BTRFS snapshot before upgrade...
Depends = timeshift
When = PreTransaction
Exec = /usr/bin/timeshift --create --comments "auto-snapshot before pacman upgrade" --tags D

This hook only fires when a package touches the kernel (vmlinuz), covering major updates. To trigger on every update, replace the Target section with:

ini
Type = Package
Target = *

Warning: A snapshot on every transaction can fill up disk space if you install many packages. Adjust the retention policy in Timeshift accordingly.

Alternative: the timeshift-autosnap package#

An AUR package does exactly this with finer configuration:

bash
yay -S timeshift-autosnap

Source: https://aur.archlinux.org/packages/timeshift-autosnap

It installs the hook automatically and allows configuring the maximum number of snapshots in /etc/timeshift-autosnap.conf.

Restoring from a snapshot#

Case 1: the system still boots#

If your system boots but an update broke something:

bash
# List available snapshots
sudo timeshift --list

# Restore a specific snapshot
sudo timeshift --restore --snapshot '2026-06-27-18-00-01' --target /dev/mapper/stoLocal-root

Timeshift replaces the current filesystem with the snapshot and offers to reboot. Select the date and modify the name of your virtual disk to match your disk name.

Case 2: the system won’t boot#

In the following commands, I use a typical configuration where your disk is /dev/sda and your root partition is /dev/sda2. Of course, adapt these commands to your configuration.

This is the critical scenario. If the system doesn’t boot after an update:

  1. Boot from the Arch Linux ISO
  2. Decrypt and mount your partitions (as during installation):
  3. List BTRFS snapshots:
  4. Restore with Timeshift from chroot:
  5. Reboot.
bash
cryptsetup luksOpen /dev/sda2 luks
mount /dev/mapper/stoLocal-root /mnt
btrfs subvolume list /mnt
arch-chroot /mnt timeshift --restore --snapshot '2026-06-27-18-00-01'

Or restore manually with BTRFS:

bash
# Rename the broken subvolume
mv /mnt/@ /mnt/@.broken
# Promote the snapshot to active subvolume
btrfs subvolume snapshot /mnt/@.snapshots/2026-06-27-18-00-01/snapshot /mnt/@

Verifying snapshots work#

Test your configuration before you need it:

bash
# Create a manual snapshot
sudo timeshift --create --comments "test snapshot" --tags D

# List
sudo timeshift --list

# Check space used by snapshots
btrfs filesystem df /

Rotation and cleanup#

BTRFS snapshots consume space as blocks diverge. Monitor disk space:

bash
# Total space used by snapshots
btrfs filesystem usage /

# Manual cleanup of old snapshots
sudo timeshift --delete --snapshot '2026-06-20-18-00-01'

Timeshift automatically manages rotation according to your retention rules, but keeping an eye on disk space is recommended.

Conclusion#

With BTRFS and Timeshift, Arch Linux rolling release becomes much safer. A pre-update snapshot takes less than a second, and restoration takes minutes — even from a system that won’t boot. Minimal investment for maximum safety net.

Sources#

Related articles

#tuto No image
#backup

Upgrading Proxmox Backup Server 3 to version 4

Procedure for upgrading Proxmox Backup Server 3 to version 4 based on Debian Trixie, using the pbs3to4 command and the recommended preparation steps.

Read more
#tuto No image
#linux

Upgrade Proxmox 8 to version 9

Guide to upgrading Proxmox VE 8 to version 9 (August 2025): best practices, backups, reading the changelogs, and post-upgrade checks.

Read more

Latest in #linux