How do I tell opensuse snapper to keep a snapshot forever?
- User
How do I tell opensuse snapper to keep a snapshot forever?
Assistant
In openSUSE, Snapper is a powerful snapshot tool that allows you to create, view, and restore filesystem snapshots on Btrfs file systems. It's designed to work closely with the YaST2 (Yet Another Software Tool 2) Snapshot Management module for easy snapshot management. By default, Snapper snapshots are configured with retention policies, which determine how long snapshots are kept before being automatically deleted to free up space. However, you can tell Snapper to keep a snapshot forever by pinning it.
Here's how you can pin a snapshot so that it is not automatically deleted:
-
List Snapshots: Before you can pin a snapshot, you need to know its ID. You can list all snapshots for the root file system (or any other Btrfs subvolume you have configured) using the following command:
bashsnapper list -
Find the Snapshot ID: Look for the snapshot you want to keep forever in the list. Each snapshot has a unique ID, which is a number.
-
Pin the Snapshot: Once you have the snapshot ID, you can pin it to prevent Snapper from deleting it automatically. Use the
snapper pincommand followed by the snapshot ID. For example:bashsnapper pin <snapshot_id>Replace
<snapshot_id>with the actual ID of the snapshot you want to keep forever. -
Verify the Pinning: After pinning the snapshot, you can verify its status to ensure it's correctly marked as pinned. You can do this by listing snapshots again:
bashsnapper listThe pinned snapshot should now show a 'P' in the second column, indicating its pinned status.
-
Unpinning a Snapshot: If you ever need to unpin a snapshot, you can use the
snapper unpincommand followed by the snapshot ID. This will make the snapshot eligible for deletion based on the configured retention policies:bashsnapper unpin <snapshot_id>
Important: Pinning snapshots does not affect the snapshot creation schedule or the retention policies. Pinned snapshots are simply exempt from deletion by Snapper's cleanup operations. If you have limited disk space, it's still possible for disk space to run out if you accumulate a large number of unpinned snapshots. Therefore, it's a good practice to regularly review and manage your snapshots, especially if you have critical data on pinned snapshots that can be restored from other means.
-