how do i setup snapshots in tumbleweed for btrfs

[

OSTechNix

Create Btrfs Snapshots With Snapper In openSUSE - OSTechNix

[

reddit.com

Possible to take Btrfs snapshot of the /home subvolume in ... - Reddit

youtube

Unlock the Power of openSUSE Btrfs & Snapper - YouTube

+5

sources

Setting up snapshots in openSUSE Tumbleweed for Btrfs is relatively straightforward, as Snapper is integrated into the system by default. Here's how to set it up and use it effectively:

Default Configuration

By default, openSUSE Tumbleweed formats your hard drive with the Btrfs filesystem and sets up Snapper for the root filesystem5. This means you already have a basic snapshot configuration for your root directory.

Viewing and Creating Configurations

  1. View existing Snapper configurations:
bashsudo snapper list-configs
  1. If you need to create a new configuration for a specific subvolume (e.g., /home):
bashsudo snapper create-config /home

Creating Snapshots

  • Automatic snapshots: Snapper is configured to automatically create timeline snapshots at regular intervals1.
  • Manual snapshots: Create a snapshot with a description:
bashsudo snapper create --desc "Snapshot description"

Managing Snapshots

  1. List snapshots:
bashsudo snapper list
  1. Compare snapshots:
bashsudo snapper status 1..2
  1. Restore a snapshot:
    For the root filesystem, you can usually boot into a snapshot from the GRUB menu4.

Tuning Snapper

To optimize Snapper's performance and disk usage:

  1. Edit the Snapper configuration file:
bashsudo nano /etc/snapper/configs/root
  1. Adjust the following parameters7:
  • TIMELINE_LIMIT_HOURLY
  • TIMELINE_LIMIT_DAILY
  • TIMELINE_LIMIT_WEEKLY
  • TIMELINE_LIMIT_MONTHLY
  • TIMELINE_LIMIT_YEARLY

Additional Subvolumes

To set up snapshots for other subvolumes like /home:

  1. Verify if /home is a Btrfs subvolume:
bashsudo btrfs subvolume list /
  1. If it's a subvolume, create a Snapper configuration for it:
bashsudo snapper -c home create-config /home
  1. You can then manage snapshots for /home using the same commands as for root, specifying the configuration with -c home3.

Remember to regularly perform Btrfs maintenance tasks like balancing and scrubbing to ensure optimal filesystem performance6.

sudo snapper list-configs [sudo] password for root: Config │ Subvolume ───────┼────────── garyrust@unlimited:~> sudo snapper list The config 'root' does not exist. Likely snapper is not configured. See 'man snapper' for further instructions. garyrust@unlimited:~> sudo btrfs subvolume list / ID 256 gen 770 top level 5 path @ ID 257 gen 770 top level 256 path var ID 258 gen 700 top level 256 path usr/local ID 259 gen 697 top level 256 path srv ID 260 gen 724 top level 256 path root ID 261 gen 666 top level 256 path opt ID 262 gen 770 top level 256 path home ID 263 gen 35 top level 256 path boot/grub2/x86_64-efi ID 264 gen 697 top level 256 path boot/grub2/i386-pc garyrust@unlimited:~>

youtube

Unlock the Power of openSUSE Btrfs & Snapper - YouTube

[

manual.siduction.org

Btrfs and Snapper - Siduction Manual

[

OSTechNix

Create Btrfs Snapshots With Snapper In openSUSE - OSTechNix

+5

sources

Based on the output provided, it appears that Snapper is not configured on your openSUSE Tumbleweed system. However, your system is using Btrfs with several subvolumes. Here's how you can set up Snapper for Btrfs snapshots:

  1. First, create a Snapper configuration for the root subvolume:
bashsudo snapper create-config /
  1. This will create a new subvolume for snapshots and a configuration file. Verify the configuration:
bashsudo snapper list-configs
  1. You should now see a "root" configuration listed.
  2. To enable automatic snapshots, start and enable the snapper-timeline and snapper-cleanup services:
bashsudo systemctl enable --now snapper-timeline.timer
sudo systemctl enable --now snapper-cleanup.timer
  1. For other important subvolumes like /home, you can create additional configurations:
bashsudo snapper -c home create-config /home
  1. Verify that snapshots are being created:
bashsudo snapper list

Remember to adjust Snapper's configuration files in /etc/snapper/configs/ to set appropriate limits on the number of snapshots to keep, to prevent excessive disk usage13.

After setting up Snapper, you can use it to create, manage, and restore snapshots of your Btrfs subvolumes, providing an additional layer of data protection and system recovery options136.

sudo snapper create-config /var [sudo] password for root: Creating config failed (config already exists). garyrust@unlimited:~> sudo snapper list-configs Config │ Subvolume ───────┼────────── root │ / garyrust@unlimited:~>

youtube

Unlock the Power of openSUSE Btrfs & Snapper - YouTube

[

forums.opensuse

BTRFS Subvolumes and snapper - openSUSE Forums

[

OSTechNix

Create Btrfs Snapshots With Snapper In openSUSE - OSTechNix

+5

sources

The error indicates that Snapper is already configured for the /var subvolume. To proceed, you can verify and manage the existing configuration instead of creating a new one. Here's what you can do:

Verify Existing Configuration

  1. List Snapper configurations:
bashsudo snapper list-configs

This will show all existing configurations, including the one for /var.

Manage Snapshots for /var

If Snapper is already configured for /var, you can create, list, and manage snapshots using the following commands:

  1. Create a manual snapshot:
bashsudo snapper -c var create --desc "Manual snapshot for /var"
  1. List snapshots:
bashsudo snapper -c var list
  1. Restore a snapshot:
    To restore a snapshot, use:
bashsudo snapper -c var undochange <snapshot_id>

Replace <snapshot_id> with the ID of the snapshot you want to restore.

Adjust Configuration Settings

If needed, you can modify the Snapper configuration for /var by editing its configuration file:

bashsudo nano /etc/snapper/configs/var

Adjust parameters like TIMELINE_LIMIT_HOURLY, TIMELINE_LIMIT_DAILY, etc., to control how many snapshots are retained.

Troubleshooting or Recreating Configuration

If you suspect issues with the current configuration and want to recreate it:

  1. Remove the existing configuration:
bashsudo snapper delete-config var
  1. Recreate the configuration:
bashsudo snapper create-config /var

This process ensures proper setup and management of snapshots for /var.

sudo snapper create-config /var Creating config failed (config already exists) here is my fstab. UUID=a1793935-e1da-43b4-948d-d2856237f92e / btrfs defaults 0 0 UUID=a1793935-e1da-43b4-948d-d2856237f92e /var btrfs subvol=/@/var 0 0 UUID=a1793935-e1da-43b4-948d-d2856237f92e /usr/local btrfs subvol=/@/usr/local 0 0 UUID=a1793935-e1da-43b4-948d-d2856237f92e /srv btrfs subvol=/@/srv 0 0 UUID=a1793935-e1da-43b4-948d-d2856237f92e /root btrfs subvol=/@/root 0 0 UUID=a1793935-e1da-43b4-948d-d2856237f92e /opt btrfs subvol=/@/opt 0 0 UUID=a1793935-e1da-43b4-948d-d2856237f92e /home btrfs subvol=/@/home 0 0 UUID=a1793935-e1da-43b4-948d-d2856237f92e /boot/grub2/x86_64-efi btrfs subvol=/@/boot/grub2/x86_64-efi 0 0 UUID=a1793935-e1da-43b4-948d-d2856237f92e /boot/grub2/i386-pc btrfs subvol=/@/boot/grub2/i386-pc 0 0 UUID=5E21-21AD /boot/efi vfat utf8 0 2

[

Oracle Help Center

Automating File System Snapshots With the Snapper Utility

[

unix.stackexchange

How to configure snapper for home (restore snapper config)

[

manual.siduction.org

Btrfs and Snapper - Siduction Manual

+5

sources

The error occurs because your /var is configured as a nested subvolume under the root Btrfs subvolume (@/var). Here's how to resolve this:

Key Issue

  • Your /var path in fstab uses subvol=/@/var, making it a nested subvolume under the root (@)
  • Snapper requires top-level subvolumes for independent configurations

Solution Steps

  1. Delete existing invalid configuration:
bashsudo snapper delete-config var
  1. Convert nested subvolume to top-level:
bashsudo mv /var /var.old
sudo btrfs subvolume create /var
sudo cp -a /var.old/* /var/
sudo rm -rf /var.old
  1. Update fstab entry:
    Change from:
bashUUID=... /var btrfs subvol=/@/var 0 0

To:

bashUUID=... /var btrfs subvol=/var,noatime,compress=zstd 0 0
  1. Create valid Snapper config:
bashsudo snapper -c var create-config /var

Verification

After these changes:

bashsudo snapper list-configs  # Should now show 'var' config
sudo btrfs subvolume list /  # Should show /var as top-level subvolume

Why This Works

  • Separates /var from root's subvolume hierarchy7
  • Allows independent snapshot management5
  • Maintains proper Btrfs subvolume structure1

Important: Ensure you have backups before modifying subvolume structures. The cp -a command preserves permissions and attributes during migration.

Related

How can I rename an existing Snapper configuration

What should I do if the Snapper configuration file is corrupted

How do I list all the Snapper configurations on my system

Can I automate the creation of Snapper configurations for multiple subvolumes

How do I revert to a previous snapshot using Snapper