Skip to content
Creating Btrfs Snapshots Using Snapper

Creating Btrfs snapshots using snapper

Example OpenSuse MicroOS Btrfs snapshots

Yes, you can manually take a Btrfs snapshot at any time before making a major change. openSUSE MicroOS includes a tool called snapper specifically for managing these snapshots. [1, 2]

Because MicroOS uses a read-only root file system, the way you take and use snapshots depends on whether you are modifying system packages or changing configuration files in /etc. [1]

Scenario 1: Manually snapshotting before system/package updates

When you use transactional-update, MicroOS automatically creates a snapshot for you. However, if you want to explicitly create a manual system restore point first, you can use snapper: [1]

  1. Create the snapshot:

    bash

    sudo snapper create --description "Before major Caddy upgrade"

    Use code with caution.

  2. List your snapshots to see the ID number of the one you just made:

    bash

    sudo snapper list

    Use code with caution.

Scenario 2: Protecting changes to configuration files (The /etc directory)

On MicroOS, user configurations live in /etc. By default, snapper is configured to track changes to your system files, but configuration files in /etc are handled slightly differently during rollbacks because they are writable.

If you plan to heavily modify text files (like a Caddyfile or systemd configs) and want a quick way to undo mistakes without rebooting:

  1. Create a comparison snapshot:

    bash

    sudo snapper create --description "Config backup"

    Use code with caution.

    (Note the number assigned to this snapshot, let’s say it is #15).

  2. Make your changes to your configuration files.

  3. See exactly what changed:
    If you make a mistake, you can see the exact lines of text you changed compared to your snapshot:

    bash

    sudo snapper status 15..currentsudo snapper diff 15..current

    Use code with caution.

  4. Undo your configuration changes:
    To instantly revert your configuration files back to the exact state of snapshot #15 without rebooting the VM, run:

    bash

    sudo snapper undochange 15..current

    Use code with caution.

How to Roll Back the Entire OS (The Ultimate Safety Net)

If a package update or system modification breaks the VM entirely, you can use your snapshot to roll back the whole machine:

  1. Reboot the VM.

  2. On the GRUB boot menu, select “Start bootloader from a read-only snapshot” and pick your manual snapshot from the list.

  3. Once the system boots up and you verify everything works, permanently set the system to use this older snapshot by running:

    bash

    sudo snapper rollback

    Use code with caution.

  4. Reboot one last time, and your machine is permanently restored. [1, 2, 3]

Knowing that you use virt-manager and .qcow2 for production, would you like to see how to use qemu-img live snapshots so you can take external VM backups without shutting down your production services?