btrfs 스냅샷 백업에서 복원하는 방법

btrfs 스냅샷 백업에서 복원하는 방법

내 Debian Bullseye 상자에 btrfs 파일 시스템이 있고 시스템 스냅샷을 찍도록 btrfs를 설정했습니다. 최근에 Cinnamon 데스크탑을 손상시키는 항목을 변경하여 마지막으로 알려진 작업 스냅샷에서 복원하고 싶었습니다.

일부 배경:

$ sudo snapper --version
snapper 0.8.14
flags btrfs,lvm,no-ext4,xattrs,rollback,btrfs-quota,no-selinux
$ cat /etc/fstab 
UUID="12345678-1337-c0d3-1111-deadbeef0abc"     /boot       btrfs   rw,noatime,nodiratime,subvol=@boot_debian               02
UUID="12345678-1337-c0d3-1111-deadbeef1abc"     /           btrfs   rw,noatime,nodiratime,subvol=@root_debian           01
UUID="12345678-1337-c0d3-1111-deadbeef1abc"     /.snapshots btrfs   rw,noatime,nodiratime,subvol=@root_debian/.snapshots    0       1
$ sudo btrfs subvolume list /
ID 256 gen 6 top level 5 path @
ID 257 gen 59305 top level 5 path @root_debian
ID 258 gen 8 top level 5 path @root_kali
ID 362 gen 59301 top level 257 path .snapshots
ID 363 gen 53701 top level 362 path .snapshots/1/snapshot
ID 365 gen 53800 top level 362 path .snapshots/2/snapshot
ID 380 gen 54783 top level 362 path .snapshots/13/snapshot
ID 382 gen 54810 top level 362 path .snapshots/14/snapshot
[...]
ID 465 gen 59247 top level 362 path .snapshots/84/snapshot
ID 466 gen 59301 top level 362 path .snapshots/85/snapshot
$ sudo snapper list
  # | Type   | Pre # | Date                            | User | Cleanup  | Description            | Userdata     
----+--------+-------+---------------------------------+------+----------+------------------------+--------------
 0  | single |       |                                 | root |          | current                |              
 1  | single |       | Sat 19 Dec 2020 02:16:27 PM CET | root |          | Fingerprint working.   |              
 2  | single |       | Sat 19 Dec 2020 03:00:04 PM CET | root | timeline | timeline               |              
13  | single |       | Sun 20 Dec 2020 10:16:35 AM CET | root | timeline | timeline               |              
14  | pre    |       | Sun 20 Dec 2020 10:23:36 AM CET | root | number   | apt                    |              
15  | post   |    14 | Sun 20 Dec 2020 10:23:56 AM CET | root | number   | apt                    |              
16  | pre    |       | Sun 20 Dec 2020 10:58:37 AM CET | root | number   | apt                    |              
17  | post   |    16 | Sun 20 Dec 2020 10:58:57 AM CET | root | number   | apt                    |              
[...]
57  | pre    |       | Tue 22 Dec 2020 08:29:33 PM CET | root | number   | apt                    |              
58  | post   |    57 | Tue 22 Dec 2020 08:29:37 PM CET | root | number   | apt                    |              
59  | single |       | Wed 23 Dec 2020 04:54:59 PM CET | root | timeline | timeline               |              
60  | single |       | Wed 23 Dec 2020 05:00:00 PM CET | root | timeline | timeline               |              
61  | pre    |       | Wed 23 Dec 2020 05:01:06 PM CET | root | number   | apt                    |              
62  | post   |    61 | Wed 23 Dec 2020 05:02:48 PM CET | root | number   | apt                    |              
63  | single |       | Wed 23 Dec 2020 05:18:54 PM CET | root | number   | boot                   |              
64  | pre    |       | Wed 23 Dec 2020 05:24:14 PM CET | root | number   | apt                    |              
65  | post   |    64 | Wed 23 Dec 2020 05:24:20 PM CET | root | number   | apt                    |              
66  | pre    |       | Wed 23 Dec 2020 05:24:26 PM CET | root | number   | apt                    |              
67  | post   |    66 | Wed 23 Dec 2020 05:24:29 PM CET | root | number   | apt                    |              
68  | single |       | Wed 23 Dec 2020 05:28:00 PM CET | root | number   | boot                   |              
69  | single |       | Wed 23 Dec 2020 05:47:26 PM CET | root | number   | boot                   |              
70  | single |       | Wed 23 Dec 2020 06:00:02 PM CET | root | timeline | timeline               |              
71  | pre    |       | Wed 23 Dec 2020 06:05:08 PM CET | root | number   | apt                    |              
72  | post   |    71 | Wed 23 Dec 2020 06:05:14 PM CET | root | number   | apt                    |              
73  | pre    |       | Wed 23 Dec 2020 06:26:24 PM CET | root | number   | apt                    |              
74  | post   |    73 | Wed 23 Dec 2020 06:26:28 PM CET | root | number   | apt                    |              
75  | single |       | Wed 23 Dec 2020 06:59:10 PM CET | root | number   | boot                   |              
76  | single |       | Wed 23 Dec 2020 07:01:38 PM CET | root | number   | boot                   |              
77  | single |       | Wed 23 Dec 2020 07:26:49 PM CET | root | number   | boot                   |              
81  | single |       | Wed 23 Dec 2020 07:30:08 PM CET | root |          | writable copy of #58   |              
82  | single |       | Wed 23 Dec 2020 07:39:01 PM CET | root | number   | rollback backup of #57 | important=yes
83+ | single |       | Wed 23 Dec 2020 07:39:01 PM CET | root |          | writable copy of #57   |              
84  | single |       | Wed 23 Dec 2020 07:41:19 PM CET | root | number   | boot                   |              
85  | single |       | Wed 23 Dec 2020 08:00:11 PM CET | root | timeline | timeline               |

rootflags=subvol=@root_debian내 grub 항목은 기본적으로 시작됩니다. @root_debian으로 바꾸고 싶습니다 snapshot 58. 어떻게 해야 합니까? 감사해요!

답변1

Live CD로 부팅할 수도 있습니다. 여기에서 btrfs 하위 볼륨을 조작하여 @root_debian을 대상 스냅샷으로 바꿀 수 있습니다:

# mount <yourDefaultBtrfsSubVolume> /mnt
# btrfs subvol snapshot /mnt/@root_debian/.snapshots/58/snapshot /mnt/@root_debian

바라보다https://www.linuxsecrets.com/archlinux-wiki/wiki.archlinux.org/index.php/Snapper.html#Restoring_.2F_to_a_previous_snapshot_of_.40

또한 다음을 선택하는 경우:

$ sudo snapper rollback 83

귀하의 의견에서 언급했듯이 다음과 같이 grub 설치를 새로 고쳐야 할 수도 있습니다.https://wiki.archlinux.org/index.php/User:I2Oc9/Root_on_Btrfs_with_LUKS_full_disk_encryption#Rollback_root_filesystem

관련 정보