This page help customer setup a ceph file system snapshot schedule. And, Setup Samba server shadow copy backed by Cephfs
A Ceph File System (CephFS) can schedule snapshots of a file system directory. The scheduling of snapshots is managed by the Ceph Manager, and relies on Python Timers. The snapshot schedule data is stored as an object in the CephFS metadata pool, and at runtime, all the schedule data lives in a serialized SQLite database.
Snapshot schedules are identified by the file system path, the repeat interval, and the start time. The repeat interval defines the time between two subsequent snapshots. The interval format is a number plus a time designator: h
(our), d
(ay), or w
(eek). For example, having an interval of 4h
, means one snapshot every four hours. The start time is a string value in the ISO format, %Y-%m-%dT%H:%M:%S
, and if not specified, the start time uses a default value of last midnight. For example, you schedule a snapshot at 14:45
, using the default start time value, with a repeat interval of 1h
, the first snapshot will be taken at 15:00.
Retention policies are identified by the file system path, and the retention policy specifications. Defining a retention policy consist of either a number plus a time designator or a concatenated pair in the format of COUNTTIME_PERIOD
. The policy ensures that a number of snapshots are kept, and the snapshots are at least for a specified time period apart. The time period designators are: h
(our), d
(ay),w
(eek), m
(onth), y
(ear), and n
. The n
time period designator is a special modifier, which means to keep the last number of snapshots regardless of timing. For example, 4d
means keeping four snapshots that are at least one day, or longer apart from each other.
Prerequisites:
- Pacific ceph cluster or later
- Active and running ceph file system
- CephFS snapshot schedule module enabled
Step1: Enable Ceph file system snapshot schedule
# enable snap schedule ceph mgr module enable snap_schedule # check if snap schedule is active ceph mgr module ls |grep snap_schedule snap_schedule on
Step2: Add snap schedule to path
Command to add a schedule to a path
ceph fs snap-schedule add FILE_SYSTEM_VOLUME_PATH REPEAT_INTERVAL [START_TIME] --fs CEPH_FILE_SYSTEM_NAME
For example:
when the ceph file system name is cephfs.
# add snap schedule to / or other path like /template/iso # for example add /tmplate/iso witch will run snapshot every hour, starting from the default value last midnight. ceph fs snap-schedule add /template/iso 1h --fs cephfs
Step3: Add snapshot retention policy to the path
The command
ceph fs snap-schedule retention add FILE_SYSTEM_VOLUME_PATH [COUNT_TIME_PERIOD_PAIR] TIME_PERIOD COUNT
Example
# add retention to keep the max number of snapshots # make snapshot for /template/iso to keep max 24 snapshots at least one hour apart. ceph fs snap-schedule retention add /template/iso h 24 --fs cephfs # make snapshot for /template/iso to keep 12 hourly, and 3 weekly snaps ceph fs snap-schedule retention add /template/iso 12h3w --fs cephfs
# List snapshot schedule ceph fs snap-schedule list FILE_SYSTEM_VOLUME_PATH [--format=plain|json] [--recursive=true]
Step4: Active all snapshot schedules
# active the target path ceph fs snap-schedule activate /template/iso --fs cephfs # active all schedule behide the root directory ceph fs snap-schedule activate / --fs cephfs
Step5: Check Snapshot schedule status
# Get snapshot schedule information ceph fs snap-schedule status /template/iso {"fs": "ec42fs", "subvol": null, "path": "/template/iso", "rel_path": "/template/iso", "schedule": "1h", "retention": {"h": 24}, "start": "2024-08-16T00:00:00", "created": "2024-08-16T07:28:54", "first": "2024-08-16T08:00:00", "last": "2024-08-16T08:00:00", "last_pruned": null, "created_count": 1, "pruned_count": 0, "active": true}
Setup Samba server shadow copy for cephfs
To enable the samba server able to see the snapshots, you have to configure the smb.conf file on the samba server.
Step1: prepare a samba server and make ceph fs as it's backend
Step2: check .snap directory under the snapshot path
Go to the samba server mount folder and verify the folder output. What you need is to get the format of the snapshot folders' name.
There is a hide folder under the folder the snapshots was take. For the above example, list the folder /template/iso/.snap
The output of snapshots folders will look like scheduled-2024-08-16-00_00_00_UTC or _scheduled-2024-08-16-10_00_00_UTC_1099513208924
Copy the format when you add configurations to the smb.conf
Step3: Add shadow into samba conf: /etc/samba/smb.conf
vfs objects = shadow_copy2 shadow:format = _scheduled-%Y-%m-%d-%H_%M_%S_UTC_1099513208924 shadow:snapdirseverywhere = yes shadow:snapdir = .snap
Step4: Restart samba server
systemctl restart smbd
Check Previous Versions of the samba share properties.
'