Scope/Description
This article will show how to manually create a cephfs snapshots and then walk through the process of setting up automated hourly,daily,weekly,monthly, and/or yearly.
Prerequisites
- An existing Nautilus ceph cluster with cephfs configured
- When using ceph-ansible-45d to build the cluster, this process is to be done after running the “core.yml”, “cephfs.yml”, “dashboard.yml” playbook
Steps
Manual Snapshots
To take a snapshot:
-
From a client where the cephFS is mounted, navigate to directory you want to snapshot.
[root@lab-ceph1 ~]# cd /mnt/cephfs/data/.snap [root@lab-ceph1 data/]# cd .snap [root@lab-ceph1 .snap]# mkdir new_snap_03-02-18
To recover files from snapshot:
-
From a client where the cephFS is mounted, navigate to directory you want to recover the file.
[root@lab-ceph1 ~]# cd /mnt/cephfs/data [root@lab-ceph1 data]# cd .snap
-
Find the correct snapshot,
[root@lab-ceph1 .snap]# cd new_snap_03-02-18
-
Find the file(s) you want to recover
[root@lab-ceph1 new_snap_03-02-18]# cp -R {file(s)} /mnt/cephfs/data
To delete snapshot: [root@lab-ceph1 .snap]# cd /mnt/cephfs/data/.snap [root@lab-ceph1 .snap]# rmdir new_snap_03-02-18
Automated Snapshots
Use cephfs-snap to automatically create and delete old snapshots.
Download file to /usr/bin
[root@lab-ceph1 ~]# curl -o /usr/bin/cephfs-snap http://images.45drives.com/ceph/cephfs/cephfs-snap
[root@lab-ceph1 ~]# chmod +x /usr/bin/cephfs-snap
Designed to be used with /etc/cron.{hourly,daily,weekly,monthly}
Usage Example:
To take hourly snaps, and delete the old ones after 24, create a file "/etc/cron.hourly/cephfs-snap" And place the following in the file #!/bin/bash cephfs-snap /mnt/cephfs/ hourly 24 To take monthly snaps and delete the old ones after 12 months, create a file "/etc/cron.monthly/cephfs-snap" And place the following in the file #!/bin/bash cephfs-snap /mnt/cephfs monthly 12
The cron file created must be set executable
[root@lab-ceph1 ~]# chmod +x /etc/cron.daily/cephfs-snap
Verification
- To verify that the cron task configured will execute properly, manually run the cron.* script created in the steps above
[root@lab-ceph1 ~]# /etc/cron.daily/cephfs-snap
- Now check that the cephfs snap shot was created in the .snap directory
[root@lab-ceph1 ~]# ls -al /mnt/cephfs/.snap
Troubleshooting
-
If the cron does not trigger a snap when expected, verify that both the “/usr/bin/cephfs-snap” and your “/etc/cron.*/cephfs-snap” files are executable
Views: 1621