SUSE Enterprise Storage 6
Customer needs to implement cephfs snapshots and basic understanding of snapshots.
How cephfs snapshots works:
cephfs snapshots are managed in the ".snap" subdirectory.
Snapshots can be created/deleted as often as desired. (Hourly, Daily, Weekly, etc...)
Example how to create cephfs snapshots:
Note: Each snapshot is a read only view of the parent directory at the time the snapshot directory was created:
Create file “test-1” and “snapshot01”:
cephfs-client:/mnt/cephfs/compression # ll
total 0
cephfs-client:/mnt/cephfs/compression # touch test01
cephfs-client:/mnt/cephfs/compression # cd .snap
cephfs-client:/mnt/cephfs/compression/.snap # mkdir snapshot01
cephfs-client:/mnt/cephfs/compression/.snap # ll snapshot01/
total 0
-rw-r--r-- 1 root root 0 May 15 09:19 test01
Create file “test-2” and “snapshot02”:
cephfs-client:/mnt/cephfs/compression # touch test02
cephfs-client:/mnt/cephfs/compression # ll
total 0
-rw-r--r-- 1 root root 0 May 15 09:19 test01
-rw-r--r-- 1 root root 0 May 15 09:20 test02
cephfs-client:/mnt/cephfs/compression/.snap # mkdir snapshot02
cephfs-client:/mnt/cephfs/compression/.snap # ll snapshot02/
total 0
-rw-r--r-- 1 root root 0 May 15 09:19 test01
-rw-r--r-- 1 root root 0 May 15 09:20 test02
cephfs-client:/mnt/cephfs/compression/.snap # ll snapshot01/
total 0
-rw-r--r-- 1 root root 0 May 15 09:19 test01
Create file “test-3” and “snapshot03”:
cephfs-client:/mnt/cephfs/compression # touch test03
cephfs-client:/mnt/cephfs/compression # ll
total 0
-rw-r--r-- 1 root root 0 May 15 09:19 test01
-rw-r--r-- 1 root root 0 May 15 09:20 test02
-rw-r--r-- 1 root root 0 May 15 09:22 test03
cephfs-client:/mnt/cephfs/compression/.snap # mkdir snapshot03
cephfs-client:/mnt/cephfs/compression/.snap # ll snapshot03/
total 0
-rw-r--r-- 1 root root 0 May 15 09:19 test01
-rw-r--r-- 1 root root 0 May 15 09:20 test02
-rw-r--r-- 1 root root 0 May 15 09:22 test03
cephfs-client:/mnt/cephfs/compression/.snap # ll snapshot02/
total 0
-rw-r--r-- 1 root root 0 May 15 09:19 test01
-rw-r--r-- 1 root root 0 May 15 09:20 test02
cephfs-client:/mnt/cephfs/compression/.snap # ll snapshot01/
total 0
-rw-r--r-- 1 root root 0 May 15 09:19 test01
Example how to recover data from snapshots:
Now deleting “test01” and creating "snapshot04":
cephfs-client:/mnt/cephfs/compression # rm test01
cephfs-client:/mnt/cephfs/compression # ll
total 0
-rw-r--r-- 1 root root 0 May 15 09:20 test02
-rw-r--r-- 1 root root 0 May 15 09:22 test03
cephfs-client:/mnt/cephfs/compression/.snap # mkdir snapshot04
cephfs-client:/mnt/cephfs/compression/.snap # ll snapshot04/
total 0
-rw-r--r-- 1 root root 0 May 15 09:20 test02
-rw-r--r-- 1 root root 0 May 15 09:22 test03
Note: “test01 was deleted, but still exists in each of the older snapshots.
cephfs-client:/mnt/cephfs/compression/.snap # ll snapshot03/
total 0
-rw-r--r-- 1 root root 0 May 15 09:19 test01
-rw-r--r-- 1 root root 0 May 15 09:20 test02
-rw-r--r-- 1 root root 0 May 15 09:22 test03
cephfs-client:/mnt/cephfs/compression/.snap # ll snapshot02/
total 0
-rw-r--r-- 1 root root 0 May 15 09:19 test01
-rw-r--r-- 1 root root 0 May 15 09:20 test02
cephfs-client:/mnt/cephfs/compression/.snap # ll snapshot01/
total 0
-rw-r--r-- 1 root root 0 May 15 09:19 test01
Recover “test01” from the most resent snapshot. I would assume that this would be the most typical use case, but the could be reasons for choosing the file from a previous snapshot as well.
cephfs-client:/mnt/cephfs/compression/.snap/snapshot03 # ll
total 0
-rw-r--r-- 1 root root 0 May 15 09:19 test01
-rw-r--r-- 1 root root 0 May 15 09:20 test02
-rw-r--r-- 1 root root 0 May 15 09:22 test03
cephfs-client:/mnt/cephfs/compression/.snap/snapshot03 # cp test01 /mnt/cephfs/compression/
Note: “test01” was recovered from the snapshot.
cephfs-client:/mnt/cephfs/compression # ll
total 0
-rw-r--r-- 1 root root 0 May 15 09:27 test01
-rw-r--r-- 1 root root 0 May 15 09:20 test02
-rw-r--r-- 1 root root 0 May 15 09:22 test03
Snapshotting will use extra disk space as it keep versions of the files:
Example: Add data to “test01”
cephfs-client:/mnt/cephfs/compression # echo "this is a test" > test01
cephfs-client:/mnt/cephfs/compression/.snap # mkdir snapshot05
cephfs-client:/mnt/cephfs/compression/.snap # cd snapshot05
cephfs-client:/mnt/cephfs/compression/.snap/snapshot05 # ll
total 1
-rw-r--r-- 1 root root 15 May 15 09:42 test01
-rw-r--r-- 1 root root 0 May 15 09:20 test02
-rw-r--r-- 1 root root 0 May 15 09:22 test03
cephfs-client:/mnt/cephfs/compression/.snap/snapshot05 # cat test01
this is a test
Now add more data to “test01” and create "snapshot06"
cephfs-client:/mnt/cephfs/compression # echo "this is another test" >> test01
cephfs-client:/mnt/cephfs/compression # cat test01
this is a test
this is another test
Note: Each snapshot has its own version of “tes01” with it unique content.
cephfs-client:/mnt/cephfs/compression/.snap # mkdir snapshot06
cephfs-client:/mnt/cephfs/compression/.snap # cd snapshot06
cephfs-client:/mnt/cephfs/compression/.snap/snapshot06 # cat test01
this is a test
this is another test
cephfs-client:/mnt/cephfs/compression/.snap # cd snapshot05
cephfs-client:/mnt/cephfs/compression/.snap/snapshot05 # cat test01
this is a test
How to delete a snapshot:
cephfs-client:/mnt/cephfs/compression/.snap # ll
total 0
drwxr-xr-x 2 root root 1 May 15 09:19 snapshot01
drwxr-xr-x 2 root root 2 May 15 09:20 snapshot02
drwxr-xr-x 2 root root 3 May 15 09:22 snapshot03
drwxr-xr-x 2 root root 2 May 15 09:24 snapshot04
drwxr-xr-x 2 root root 3 May 15 09:27 snapshot05
drwxr-xr-x 2 root root 3 May 15 09:27 snapshot06
cephfs-client:/mnt/cephfs/compression/.snap # rmdir snapshot01
cephfs-client:/mnt/cephfs/compression/.snap # ll
total 0
drwxr-xr-x 2 root root 2 May 15 09:20 snapshot02
drwxr-xr-x 2 root root 3 May 15 09:22 snapshot03
drwxr-xr-x 2 root root 2 May 15 09:24 snapshot04
drwxr-xr-x 2 root root 3 May 15 09:27 snapshot05
drwxr-xr-x 2 root root 3 May 15 09:27 snapshot06
Top Issue
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.