Utility to help manage btrfs snapshots on Slackware linux with elilo UEFI boot

Bernardo Magri 1d32475744 fixing slackbuild 1 yıl önce
README.md 240e8bd9c6 Update 'README.md' 1 yıl önce
config.toml 4c1dcfd7d9 Add 'config.toml' 1 yıl önce
snap-slack.SlackBuild 1d32475744 fixing slackbuild 1 yıl önce
snap-slack.info d71055bf34 Add 'snap-slack.info' 1 yıl önce
snap-slack.py b3726dc3ec updating 1 yıl önce

README.md

Snap-Slack: Btrfs Snapshot Manager with Elilo Bootloader Integration

Snap-Slack is a Python-based utility for managing Btrfs snapshots on Slackware Linux. It provides functionality to create snapshots, manage existing snapshots, clean up old snapshots, and adopt snapshots as the new root subvolume. The tool also integrates with the Elilo bootloader, updating the configuration automatically to include snapshots.

Features

  • Create Btrfs snapshots before system upgrades or custom tasks.
  • Manage snapshots by removing old ones and updating elilo.conf.
  • Adopt a snapshot as the new root subvolume, allowing easy rollback.
  • Automatically updates Elilo bootloader entries for snapshots.

Prerequisites

  • Python 3.x
  • Btrfs installed and set up on your root filesystem.
  • Elilo bootloader configured on your system.
  • Slackware or Slackware-based system.

Installation

From SlackBuilds (Manual)

  1. Download the snap-slack.SlackBuild script and associated files.
  2. Run the SlackBuild script:

    ./snap-slack.SlackBuild
    
  3. Install the package:

    sudo installpkg /tmp/snap-slack-1.0-x86_64-1_SBo.txz
    

This will install the script to /usr/bin/snap-slack and place the configuration file at /etc/snap-slack/config.toml.

Configuration

The script reads its configuration from /etc/snap-slack/config.toml. You may need to edit this file to match your system's settings.

Here is an example configuration (/etc/snap-slack/config.toml):

[snapshot]
snapshot_dir = "/snapshots"
snapshot_prefix = "snapshot-"
btrfs_mount_point = "/mnt"
root_subvolume = "@"
retention_days = 7

[elilo]
elilo_conf = "/boot/efi/EFI/Slackware/elilo.conf"
root_partition = "/dev/sdaX"

Key Configuration Parameters

  • snapshot_dir: Directory where Btrfs snapshots are stored.
  • snapshot_prefix: Prefix for snapshot names.
  • btrfs_mount_point: Mount point for the Btrfs volume.
  • root_subvolume: Name of the current root subvolume (usually @).
  • retention_days: Number of days to retain snapshots before automatic deletion.
  • elilo_conf: Path to elilo.conf.
  • root_partition: Device name for the root partition (e.g., /dev/sdaX).

Usage

Once installed, you can use the snap-slack command to manage Btrfs snapshots and integrate them with Elilo.

Create a Snapshot

To create a new Btrfs snapshot of the root subvolume, run:

snap-slack create

The script will:

  • Create a new snapshot with a timestamp.
  • Add the snapshot to the elilo.conf bootloader configuration.

Manage Snapshots

To manage existing snapshots (e.g., clean up old snapshots and update elilo.conf), run:

snap-slack manage

This will:

  • Remove snapshots older than the retention period specified in the configuration.
  • Ensure that elilo.conf has entries for all valid snapshots.

Adopt a Snapshot as the New Root Subvolume

If you want to adopt a specific snapshot as the new root subvolume (rollback to a previous state), run:

snap-slack adopt --snapshot <snapshot_name>

For example:

snap-slack adopt --snapshot snapshot-20231015-123456

This will:

  • Rename the current root subvolume (usually @) to something like @_old.
  • Rename the specified snapshot to @, making it the active root subvolume.
  • Update elilo.conf to use the new root subvolume.

Examples

Creating a Snapshot Before System Upgrade

snap-slack create
slackpkg upgrade-all

This ensures that a snapshot is taken before performing a system upgrade.

Rolling Back to a Previous Snapshot

If your system has issues after a recent change, you can roll back to a previous snapshot:

snap-slack adopt --snapshot snapshot-20231015-123456

This will set snapshot-20231015-123456 as the new root subvolume.

Known Issues

  • Make sure the Btrfs volume is not mounted as read-only when renaming subvolumes.
  • Ensure that elilo.conf is correctly updated after adopting a snapshot.

Contributing

If you'd like to contribute to Snap-Slack, feel free to open an issue or submit a pull request on the project's repository.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Support

For help or support, feel free to open an issue on the repository.