CephFS includes snapshot and scheduling capabilities. That’s very efficient and super handy.
CephFS snapshots are different from the Ceph RBD snapshots covered here.
You might already know that you can easily create a snapshot of any folder or subfolder by just creating a named subfolder in the magic .snap/
subfolder.
Example:
mkdir /mnt/cephfs/docker/volumes/.snap/$(date +%Y%m%d-%Hh%M)
Very useful for temporary snapshots, or for your backup script. The name of the folder has no importance. rmdir
just removes the snapshot.
Schedules
Let’s focus on CephFS scheduled snapshots. Here is an example of commands you can use for hourly snapshots and retention.
Enable the snap_schedule
module
ceph mgr module enable snap_schedule
Check that the snapshot schedule module is enabled
Boils down to check if the snap_schedule
is part of the enabled_modules
:
root@pve1:~# ceph mgr module ls -f json | jq -r '.enabled_modules []'
dashboard
iostat
nfs
prometheus
restful
snap_schedule
stats
Feel free to check all available modules with ceph mgr module ls
Create the schedule and retention
ceph fs snap-schedule add / 1h
ceph fs snap-schedule activate /
ceph fs snap-schedule retention add / m 12
ceph fs snap-schedule retention add / w 4
ceph fs snap-schedule retention add / d 7
ceph fs snap-schedule retention add / h 24
Check cephfs snapshot schedule
root@pve1:~# ceph fs snap-schedule status / | jq
{
"fs": "cephfs",
"subvol": null,
"path": "/",
"rel_path": "/",
"schedule": "1h",
"retention": {
"m": 12,
"w": 4,
"d": 7,
"h": 24
},
"start": "2022-07-17T00:00:00",
"created": "2022-07-17T22:44:20",
"first": "2022-12-31T14:00:00",
"last": "2023-01-28T11:00:00",
"last_pruned": "2023-01-28T11:00:00",
"created_count": 670,
"pruned_count": 695,
"active": true
}
You should see subfolders in every .snap/
subfolder in all folders and subfolders.
Note the _
in front of the snapshot name just means the snapshot is managed from a parent folder.
root@pve1:~# ls -tr -1 /mnt/pve/cephfs/.snap | head
weekly_2022-07-10_231701
daily_2022-07-10_231701
scheduled-2023-01-28-12_00_00
scheduled-2023-01-28-11_00_00
scheduled-2023-01-28-10_00_00
scheduled-2023-01-28-09_00_00
scheduled-2023-01-28-08_00_00
scheduled-2023-01-28-07_00_00
scheduled-2023-01-28-06_00_00
scheduled-2023-01-28-05_00_00
root@pve1:~# ls -tr -1 /mnt/pve/cephfs/docker/volumes/.snap | head
_weekly_2022-07-10_231701_1
_daily_2022-07-10_231701_1
_scheduled-2023-01-28-12_00_00_1
_scheduled-2023-01-28-11_00_00_1
_scheduled-2023-01-28-10_00_00_1
_scheduled-2023-01-28-09_00_00_1
_scheduled-2023-01-28-08_00_00_1
_scheduled-2023-01-28-07_00_00_1
_scheduled-2023-01-28-06_00_00_1
_scheduled-2023-01-28-05_00_00_1
Each of these .snap/
subfolders contains a read-only version of the folder as it was at the time of the snapshot.
Et voilà !