# 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 - **List snapshots** with creation date and age information - **Manage snapshots** by removing old ones based on retention policy - **Boot into snapshots** directly from the Elilo bootloader menu - **Adopt a snapshot** as the new root subvolume, allowing easy rollback - **Verify system configuration** to ensure proper setup - **Detailed logging** for troubleshooting - **Automatic recovery** in case of errors during critical operations ## Prerequisites - **Python 3.x** - **Btrfs** installed and set up on your root filesystem - **Elilo bootloader** configured on your system - **toml** Python package (for configuration file parsing) - Slackware or Slackware-based system ## Installation ### From SlackBuild 1. Download the `snap-slack.SlackBuild` script and associated files 2. Run the SlackBuild script: ```bash ./snap-slack.SlackBuild ``` 3. Install the package: ```bash sudo installpkg /tmp/snap-slack-2.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 should edit this file to match your system's settings before using snap-slack. Here is an explanation of the configuration parameters: ### [snapshot] Section - `snapshot_dir`: Directory where Btrfs snapshots are stored (e.g., `/.snapshots`) - `snapshot_prefix`: Prefix for snapshot names (e.g., `snapshot-`) - `btrfs_mount_point`: Mount point for the Btrfs volume (usually `/`) - `root_subvolume`: Name of the current root subvolume (usually `@` in Slackware) - `retention_days`: Number of days to retain snapshots before automatic deletion ### [bootloader] Section - `type`: Specify either `elilo` or `grub` depending on your system's bootloader ### [elilo] Section (when using ELILO bootloader) - `elilo_conf`: Path to `elilo.conf` (e.g., `/boot/efi/EFI/Slackware/elilo.conf`) - `root_partition`: Device name for the root partition (e.g., `/dev/sda2`) - `extra_boot_options`: Additional kernel parameters (e.g., `quiet splash`) ### [grub] Section (when using GRUB bootloader) - `use_custom_file`: Set to `true` to use a custom file in /etc/grub.d/ (recommended) - `custom_entries_file`: Path to the custom file (e.g., `/etc/grub.d/60_snap-slack`) - `config_file`: Path to GRUB configuration file (e.g., `/boot/grub/grub.cfg`) - `root_partition`: Device name for the root partition (e.g., `/dev/sda2`) - `kernel_path`: Path to the kernel image (e.g., `/boot/vmlinuz`) - `initrd_path`: Path to the initrd image (e.g., `/boot/initrd.gz`) - `extra_boot_options`: Additional kernel parameters (e.g., `quiet splash`) ### [boot] Section - `boot_dir`: Path to the boot directory (e.g., `/boot`) - `hostname`: System hostname (used for snapshot descriptions) ## Usage Once installed and configured, you can use the `snap-slack` command to manage Btrfs snapshots and integrate them with Elilo. ### Verify System Configuration Before using snap-slack, verify that your system is properly configured: ```bash snap-slack verify ``` This will check that your system has Btrfs installed, the root filesystem is Btrfs, and other necessary prerequisites are met. ### Create a Snapshot To create a new Btrfs snapshot of the root subvolume: ```bash snap-slack create ``` The script will: - Create a new read-only snapshot with a timestamp - Add the snapshot to the `elilo.conf` bootloader configuration ### List Snapshots To list all existing snapshots with details: ```bash snap-slack list ``` This will display a table of all snapshots, their creation dates, and ages. ### Manage Snapshots To manage existing snapshots (clean up old snapshots and update `elilo.conf`): ```bash 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 ### Configure a Snapshot for Booting To configure a specific snapshot for booting: ```bash snap-slack boot --snapshot snapshot-20240424-123456 ``` This will ensure that the snapshot is properly configured in `elilo.conf` for booting. ### 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): ```bash snap-slack adopt --snapshot snapshot-20240424-123456 ``` This will: - Create a backup of the current root subvolume - Delete the current root subvolume - Create a new root subvolume based on the selected snapshot - Provide instructions for booting into the new root filesystem ## Recovery Process ### Booting into a Snapshot When you want to boot into a snapshot to test it before adoption: 1. Create or select a snapshot: `snap-slack list` 2. Configure it for booting: `snap-slack boot --snapshot ` 3. Reboot your system 4. In the ELILO boot menu, select the entry with the snapshot name 5. Test the system ### Rolling Back to a Snapshot If you want to permanently make a snapshot your new root filesystem: 1. Boot into your normal system (not the snapshot) 2. Run: `snap-slack adopt --snapshot ` 3. Reboot 4. The system will now boot with the adopted snapshot as the root filesystem ### Emergency Recovery If something goes wrong during the adoption process: 1. Reboot your system 2. In the ELILO bootloader menu, select any working snapshot 3. After booting, you can attempt the adoption process again or troubleshoot the issue ## Advanced Usage Scenarios ### Creating a Snapshot Before System Upgrade ```bash # Create a snapshot before upgrading snap-slack create # Perform your upgrade slackpkg update slackpkg upgrade-all ``` ### Creating a Weekly Snapshot with Cron Add this to your crontab to create a weekly snapshot: ``` 0 2 * * 0 /usr/bin/snap-slack create 0 3 * * 0 /usr/bin/snap-slack manage ``` ## Logging Snap-slack logs all operations to `/var/log/snap-slack.log`. Check this file for troubleshooting if you encounter any issues. ## Known Issues and Limitations - The system doesn't support encrypted Btrfs volumes out of the box - You must have enough disk space for snapshots - The `adopt` operation requires a reboot to take effect - Be careful when setting a very short retention period as it might delete snapshots you still need ## 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. ## Support For help or support, feel free to open an issue on the repository. ---