לדלג לתוכן

btrfs & Snapper

btrfs

sudo btrfs subvolume snapshot / path/to/snapshot זה כדי ליצור סנאפשוט שלם של root (/) הסנאפשוט יכול להיכתב רק לאותו הדרייב, אז אם רוצים להעביר לדיסקונקי למשל, משתמשים ב-send וב-receive sudo btrfs send /mnt/usb/snapshots/your_snapshot | sudo btrfs receive /mnt/recovery ה | מכפיף את האאוטפוט של הראשונה לאינפוט של השניה - לשם הוא שולח עדיף לשים בסוף && עם הודעת הצלחה - בכל דבר לא ברור...

Snapper

Steps to Restore a Snapper Snapshot:

  1. List the Snapshots: Before restoring a snapshot, you can list all available snapshots. Run the following command to see all snapshots in your system:

    sudo snapper list

    This will display a list of snapshots with their IDs and other details. Each snapshot will have a corresponding snapshot number.

  2. Restore the Snapshot: Once you've identified the snapshot you want to restore (e.g., ID 5), you can proceed to restore it. Use the following command:

    sudo snapper rollback <snapshot-id>

    Replace <snapshot-id> with the ID of the snapshot you want to restore. For example, to restore snapshot ID 5, you would run:

    sudo snapper rollback 5

    This will revert the system to the state of the selected snapshot.

  3. Reboot the System: After performing the rollback, you will need to reboot your system for the changes to take effect. You can do so with the following command:

    sudo reboot

    The system will restart and should be in the state of the snapshot you restored.

Important Considerations:

  • Data Loss Warning: Restoring a snapshot will overwrite the current state of your system with the state from the snapshot. This means any files or changes made after the snapshot was taken will be lost. Be sure to back up any important data before restoring a snapshot.

  • Snapper Snapshots vs. BTRFS Snapshots: If you're using BTRFS as your filesystem, Snapper works by creating subvolume snapshots, and restoring a snapshot essentially reverts the system to that subvolume's state.

Alternative (Manual) Snapshot Restoration:

If for some reason you don't want to use the Snapper rollback feature, you can manually restore a snapshot by mounting the snapshot subvolume and copying its contents back into the root directory:

  1. Mount the Snapshot: Mount the snapshot subvolume to a temporary location (e.g., /mnt):

    sudo mount /dev/sdX /mnt # Replace /dev/sdX with your actual device

  2. Copy Files: You can then copy the snapshot files back to the root filesystem (or any other directory), but this is a more manual method and can be error-prone.