Samba & Snapper – is a command-line program for filesystem snapshot management it can create delete and compare snapshots and undo changes done between snapshots

root@rpi-iot-jsho-samba-01:/etc# snapper -c root create-config /samba/Filespace
Creating config failed (subvolume already covered).
root@rpi-iot-jsho-samba-01:/# snapper list-configs
Config | Subvolume
——-+—————–
root | /samba/Filespace
root@rpi-iot-jsho-samba-01:/# btrfs subvolume list /samba/Filespace
ID 256 gen 8013 top level 5 path Filespace
ID 5618 gen 8016 top level 256 path .snapshots
ID 5619 gen 8013 top level 5618 path .snapshots/1/snapshot
root@rpi-iot-jsho-samba-01:/# snapper list
# | Type | Pre # | Date | User | Cleanup | Description | Userdata
—+——–+——-+——————————-+——+———-+————-+———
0 | single | | | root | | current |
1 | single | | Tue 13 Oct 2020 12:00:04 CEST | root | timeline | timeline |
root@rpi-iot-jsho-samba-01:/#
root@rpi-iot-jsho-samba-01:/# snapper -c root create
root@rpi-iot-jsho-samba-01:/# snapper list
# | Type | Pre # | Date | User | Cleanup | Description | Userdata
—+——–+——-+——————————-+——+———-+————-+———
0 | single | | | root | | current |
1 | single | | Tue 13 Oct 2020 12:00:04 CEST | root | timeline | timeline |
2 | single | | Tue 13 Oct 2020 12:12:47 CEST | root | | |
3 | single | | Tue 13 Oct 2020 12:14:17 CEST | root | | |
root@rpi-iot-jsho-samba-01:/# btrfs subvolume list /samba/Filespace
ID 256 gen 8020 top level 5 path Filespace
ID 5618 gen 8021 top level 256 path .snapshots
ID 5619 gen 8013 top level 5618 path .snapshots/1/snapshot
ID 5620 gen 8017 top level 5618 path .snapshots/2/snapshot
ID 5621 gen 8020 top level 5618 path .snapshots/3/snapshot
root@rpi-iot-jsho-samba-01:~# snapper list
# | Type | Pre # | Date | User | Cleanup | Description | Userdata
—+——–+——-+——————————-+——+———+————-+———
0 | single | | | root | | current |
1 | single | | Tue 13 Oct 2020 13:55:14 CEST | root | | |
2 | single | | Tue 13 Oct 2020 13:55:29 CEST | root | | |
root@rpi-iot-jsho-samba-01:~# snapper -c root delete 1-2
root@rpi-iot-jsho-samba-01:~# snapper list
# | Type | Pre # | Date | User | Cleanup | Description | Userdata
—+——–+——-+——+——+———+————-+———
0 | single | | | root | | current |
Set snapshot limits – the default settings will keep 10 hourly, 10 daily, 10 monthly and 10 yearly snapshots
root@rpi-iot-jsho-samba-01:/# vi /etc/snapper/configs/root
# subvolume to snapshot
SUBVOLUME=“/samba/Filespace“
# filesystem type
FSTYPE=“btrfs“
# btrfs qgroup for space aware cleanup algorithms
QGROUP=““
# fraction of the filesystems space the snapshots may use
SPACE_LIMIT=“0.5″
# fraction of the filesystems space that should be free
FREE_LIMIT=“0.2″
# users and groups allowed to work with config
ALLOW_USERS=““
ALLOW_GROUPS=““
# sync users and groups from ALLOW_USERS and ALLOW_GROUPS to .snapshots
# directory
SYNC_ACL=“no“
# start comparing pre- and post-snapshot in background after creating
# post-snapshot
BACKGROUND_COMPARISON=“yes“
# run daily number cleanup
NUMBER_CLEANUP=“yes“
# limit for number cleanup
NUMBER_MIN_AGE=“1800″
NUMBER_LIMIT=“50″
NUMBER_LIMIT_IMPORTANT=“10″
# create hourly snapshots
TIMELINE_CREATE=“yes“
# cleanup hourly snapshots after some time
TIMELINE_CLEANUP=“yes“
# limits for timeline cleanup
TIMELINE_MIN_AGE=“1800″
TIMELINE_LIMIT_HOURLY=“10″
TIMELINE_LIMIT_DAILY=“10″
TIMELINE_LIMIT_WEEKLY=“0″
TIMELINE_LIMIT_MONTHLY=“10″
TIMELINE_LIMIT_YEARLY=“10″
# cleanup empty pre-post-pairs
EMPTY_PRE_POST_CLEANUP=“yes“
# limits for empty pre-post-pair cleanup
EMPTY_PRE_POST_MIN_AGE=“1800″
root@rpi-iot-jsho-samba-01:/# snapper list
# | Type | Pre # | Date | User | Cleanup | Description | Userdata
—+——–+——-+——————————-+——+———-+————-+———
0 | single | | | root | | current |
1 | single | | Tue 13 Oct 2020 14:00:04 CEST | root | timeline | timeline |
2 | single | | Tue 13 Oct 2020 14:21:52 CEST | root | | |
3 | single | | Tue 13 Oct 2020 14:22:39 CEST | root | | |
4 | single | | Tue 13 Oct 2020 14:26:56 CEST | root | | |
5 | single | | Tue 13 Oct 2020 15:00:04 CEST | root | timeline | timeline |
6 | single | | Tue 13 Oct 2020 16:00:04 CEST | root | timeline | timeline |
root@rpi-iot-jsho-samba-01:~# snapper -c root create –description test
root@rpi-iot-jsho-samba-01:~# snapper list
# | Type | Pre # | Date | User | Cleanup | Description | Userdata
—+——–+——-+——————————-+——+———-+————-+———
0 | single | | | root | | current |
1 | single | | Tue 13 Oct 2020 14:00:04 CEST | root | timeline | timeline |
2 | single | | Tue 13 Oct 2020 14:21:52 CEST | root | | |
3 | single | | Tue 13 Oct 2020 14:22:39 CEST | root | | |
4 | single | | Tue 13 Oct 2020 14:26:56 CEST | root | | |
5 | single | | Tue 13 Oct 2020 15:00:04 CEST | root | timeline | timeline |
6 | single | | Tue 13 Oct 2020 16:00:04 CEST | root | timeline | timeline |
7 | single | | Tue 13 Oct 2020 16:14:49 CEST | root | number | boot |
8 | single | | Tue 13 Oct 2020 16:16:29 CEST | root | | test |
root@rpi-iot-jsho-samba-01:/samba/Filespace/.snapshots# snapper -v undochange 7..8
create:0 modify:1 delete:1
deleting /samba/Filespace/USB-Stick/.sync/Archive/RaspberryPi/snapper.5.txt
modifying /samba/Filespace/USB-Stick/RaspberryPi/snapper.txt
# vi /etc/samba/smb.conf
[Samba-BTRFS-Test]
comment = Samba BTRFS test folder
path = /samba/Filespace
writable = yes
browseable = yes
guest ok = yes
# systemctl restart smbd.service
# systemctl restart nmbd.service

Leave a Reply

You must be logged in to post a comment.