Skip to content

Commit 8056c23

Browse files
authored
Merge pull request ceph#61240 from neesingh-rh/wip-68974
doc: add snapshots under cephfs concepts Reviewed-by: Anthony D'Atri <[email protected]>
2 parents 4b0d458 + 885b1bf commit 8056c23

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

doc/cephfs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ CephFS Concepts
148148
LazyIO <lazyio>
149149
Directory fragmentation <dirfrags>
150150
Multiple active MDS daemons <multimds>
151+
Snapshots <snapshots>
151152

152153

153154
.. raw:: html

doc/cephfs/snapshots.rst

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
================
2+
CephFS Snapshots
3+
================
4+
5+
CephFS snapshots create an immutable view of the file system at the point
6+
in time they are taken. CephFS support snapshots which is managed in a
7+
special hidden subdirectory named ``.snap`` .Snapshots are created using
8+
``mkdir`` inside this directory.
9+
10+
Snapshots can be exposed with a different name by changing the following client configurations.
11+
12+
- ``snapdirname`` which is a mount option for kernel clients
13+
- ``client_snapdir`` which is a mount option for ceph-fuse.
14+
15+
Snapshot Creation
16+
==================
17+
18+
CephFS snapshot feature is enabled by default on new file systems. To enable
19+
it on existing file systems, use the command below.
20+
21+
.. code-block:: bash
22+
23+
$ ceph fs set <fs_name> allow_new_snaps true
24+
25+
When snapshots are enabled, all directories in CephFS will have a special ``.snap``
26+
directory. (You may configure a different name with the client snapdir setting if
27+
you wish.)
28+
To create a CephFS snapshot, create a subdirectory under ``.snap`` with a name of
29+
your choice.
30+
For example, to create a snapshot on directory ``/file1/``, invoke ``mkdir /file1/.snap/snapshot-name``
31+
32+
.. code-block:: bash
33+
34+
$ touch file1
35+
$ cd .snap
36+
$ mkdir my_snapshot
37+
38+
Using snapshot to recover data
39+
===============================
40+
41+
Snapshots can also be used to recover some deleted files.
42+
43+
- ``create a file1 and create snapshot snap1``
44+
45+
.. code-block:: bash
46+
47+
$ touch /mnt/cephfs/file1
48+
$ cd .snap
49+
$ mkdir snap1
50+
51+
- ``create a file2 and create snapshot snap2``
52+
53+
.. code-block:: bash
54+
55+
$ touch /mnt/cephfs/file2
56+
$ cd .snap
57+
$ mkdir snap2
58+
59+
- ``delete file1 and create a new snapshot snap3``
60+
61+
.. code-block:: bash
62+
63+
$ rm /mnt/cephfs/file1
64+
$ cd .snap
65+
$ mkdir snap3
66+
67+
- ``recover file1 using snapshot snap2 using cp command``
68+
69+
.. code-block:: bash
70+
71+
$ cd .snap
72+
$ cd snap2
73+
$ cp file1 /mnt/cephfs/
74+
75+
Snapshot Deletion
76+
==================
77+
78+
Snapshots are deleted by invoking ``rmdir`` on the ``.snap`` directory they are
79+
rooted in. (Attempts to delete a directory which roots the snapshots will fail;
80+
you must delete the snapshots first.)
81+
82+
.. code-block:: bash
83+
84+
$ cd .snap
85+
$ rmdir my_snapshot

0 commit comments

Comments
 (0)