You are not logged in.

#1 2023-08-16 06:52:44

KamilCuk
Member
Registered: 2021-03-02
Posts: 1

Btrfs @snapshots subvolume is not needed, why not just rsync?

There is thread https://bbs.archlinux.org/viewtopic.php?id=194491 and https://wiki.archlinux.org/title/snappe … tem_layout that recommend @snapshots. I do not understand the reason.

Let's say your system is as in the thread:

subvolid=0
└── /usr, /bin, /sbin, /.snapshots, ...

The problem is explained in the thread, but there is a simple solution. When you want to restore a previous snapshot from snapper, boot from read only snapshot with

rootflags=subvol=.snapshots/#/snapshot

. Then just mount your whole btrfs and restore the files to root partition.

# boot from readonly ./.snapshots/5/snapshot or from rescuecd
mkdir /mnt/sda1
mount /dev/sda1 /mnt/sda1  # mount whole btrfs
cd /mnt/sda1/@/  # navigate to / mountpoint in btrfs filesystem
# Just rsync the files from th snapshot to root 
rsync -aivxsAHSX --progress --one-file-system --delete --exclude  ./.snapshots  ./.snapshots/5/snapshot  ./
cd ../../../
umount /mnt/sda1
# reboot from  subvol=@

That's it. No need for a separate subvolume. My point, if you can restore single files, you can restore all files.

Last edited by KamilCuk (2023-08-16 06:55:19)

Offline

#2 2023-08-19 09:21:09

willemw
Member
Registered: 2013-02-19
Posts: 116

Re: Btrfs @snapshots subvolume is not needed, why not just rsync?

To restore some files, you usually can do that while running on the current "/" subvolume.

To restore the whole "/" subvolume:

- Boot into another root (a live USB or a "/" snapshot), as you said

- But then instead:

  Move/rename the old subvolume for "/". Can be deleted later. Then create a writable subvolume for "/". Something like:

mv @root{,.old}
btrfs subvolume /.snapshots/<some "/" snapshot> @root

Seems simple enough to remember.

In your rsync case, I would save that rsync line in a file or script somewhere, to avoid making mistakes later on. For example, I would add "--delete-excluded" and "--sparse" to that rsync line, if not already included in "-aivxsAHSX".

Offline

#3 2023-08-19 09:29:23

willemw
Member
Registered: 2013-02-19
Posts: 116

Re: Btrfs @snapshots subvolume is not needed, why not just rsync?

Also, now you still have a snapshot of the old "/" subvolume, the one before the manual rollback.

Offline

Board footer

Powered by FluxBB