|
| 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