- Forum
- Linux Forums
- How to restore BTRFS snapshot on Linux and mount snapshots under defined folder?
Advertisement: Linux VPS from $4/month - contact support for custom offer.
-
Administrator
How to restore BTRFS snapshot on Linux and mount snapshots under defined folder?
Method A)
mount /dev/root /mnt && cd /mnt/ && ls -la && cd home && ls -la
# now go to the appropriate snapshot
cd @...
cp -r xy /destination/
Method B)
Mount snapshots subvolume for current session in order to browse directories and files/copy/restore it:
mkdir /root/btrfs-snapshots;mount -o rw,relatime,ssd,space_cache,subvol=/ /dev/mmcblk0p2 /root/btrfs-snapshots
(/dev/mmcblk0p2 is the device path shown in output of the command: mount|grep "@" )
List content of the /home/user/ directory in one of the snapshots:
ls /root/btrfs-snapshots/home/@btrfs-auto-snap_daily-2023-04-24-0827/user/
Copy directory from snapshot to its original location:
cp -a --reflink=always /root/btrfs-snapshots/home/@btrfs-auto-snap_daily-2023-04-24-0827/user/directory /home/user/
(--reflink=always to prevent duplication of files (save disk space))
List snapshots:
btrfs sub list / -t
Mount snapshots on each boot:
blkid|grep btrfs
Find out UUID and copy it down, open fstab:
sudo nano /etc/fstab
append new line:
UUID="uuidhere" /root/btrfs-snapshots xbian ro,noatime,nodiratime 0 0
# replace uuidhere and xbian(by string that other mount lines in the file has) and replace ro by rw in case you need to write into snapshot filesystem. "ssd" parameter in case of a SSD drive + writing.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Protected by : ZB
BLOCK & StopForumSpam
Bookmarks