Skip to main content
RunBook Academy

CephCVII · CephFS BackupCephFS Backup

CephFS snapshots: the .snap directory and its behaviour

Intermediate⏱ ~18 minceph

What you'll learn

  • Create and remove a CephFS snapshot
  • Locate snapshot contents
  • Understand snapshot scope and cost
  • Recognise the operational limits

Prerequisites

None — start here.

Verified against Ceph Tentacle 20.2.x · Ceph Squid 19.2.x (supported previous) · cephadm matches the verified Ceph release · podman 4.x · csi-rbd and csi-cephfs current · RBD / CephFS / RGW current (matches Ceph release) · Linux kernel 5.15+ (5.10 minimum) · Ubuntu 24.04 LTS (Ceph host baseline) · Debian 12 (Bookworm) (Ceph host baseline) · Rocky Linux / RHEL / AlmaLinux 9.x (Ceph host baseline) · Proxmox VE 9.x (cross-course integration) · Kubernetes 1.31+ (cross-course integration) · 2026-08-18

Not yet marked complete on this device.

Why this matters in production

CephFS snapshots are created by making a directory, which is unlike every other snapshot mechanism and catches people out.

Creating and removing

# from a mounted client, snapshot any directory
mkdir /mnt/cephfs/projects/.snap/before-migration
ls /mnt/cephfs/projects/.snap/
# removing is rmdir
rmdir /mnt/cephfs/projects/.snap/before-migration
There is no `ceph fs snap create`. Snapshots are directory operations
performed by a client with the right capability, on any directory.
# the subvolume interface, which wraps the same mechanism
ceph fs subvolume snapshot create cephfs acme snap-20260818 --group_name tenants
ceph fs subvolume snapshot ls cephfs acme --group_name tenants
ceph fs subvolume snapshot rm cephfs acme snap-20260818 --group_name tenants
# snapshots must be permitted on the filesystem
ceph fs get cephfs | grep -i snap
ceph fs set cephfs allow_new_snaps true

Where the contents appear

ls /mnt/cephfs/projects/.snap/before-migration/
The .snap directory is virtual — it does not appear in `ls` without
being named explicitly, and it exists under every directory in the
filesystem.
# a snapshot taken at a parent is visible from children
ls /mnt/cephfs/projects/subdir/.snap/
PropertyBehaviour
Snapshot at /avisible in /a/.snap/ and /a/b/.snap/
Scopethe directory and everything beneath it
Visibilityread-only, at the moment of creation
Namingthe directory name is the snapshot name
Hidden from listings.snap is not shown by ls

Cost

A snapshot costs nothing at creation. It costs as the live tree
diverges: overwritten and deleted files retain their snapshotted
content in the data pool.
ceph df detail
ceph fs status cephfs
# metadata cost, which is the one people miss
ceph tell mds.0 perf dump 2>/dev/null | python3 -c '
import sys,json
d = json.load(sys.stdin).get("mds_mem", {})
print("inode count:", d.get("ino"), " dentries:", d.get("dn"))'
CostDriver
Data pool capacityoverwritten and deleted file content
Metadata pool capacitysnapshotted inode and dentry state
MDS memorysnapshot metadata held in cache
Deletion workremoving a snapshot releases objects to trim

Operational limits

Snapshots interact with the MDS in ways that matter at scale:
  many snapshots on a heavily-modified tree increase MDS metadata work
  snapshots on directories that are moved have historically been
    a source of complexity
  a snapshot of a very large subtree makes every subsequent metadata
    operation in that subtree slightly more expensive
ceph fs status cephfs
ceph health detail | grep -i -E 'mds|snap'
The practical guidance: snapshot at the subvolume or project level, not
at the filesystem root, and keep the count bounded.

Quiz

Knowledge check · 4 questions

  1. Q1. How is a CephFS snapshot created from a mounted client?

  2. Q2. Recovering a CephFS directory from a snapshot is always a data movement operation.

  3. Q3. Design a CephFS snapshot policy.

    A filesystem holds 40 project directories. The proposal is a daily snapshot at the filesystem root, retained for 30 days.

  4. Q4. What does a snapshot taken at `/a` cover, and where is it visible?

Passing score: 75%. Answers are checked in this browser.

Production discipline

Snapshot at the subvolume or project level rather than the filesystem root — the MDS tracks snapshot state for every inode in scope, so a root snapshot makes every metadata operation in the filesystem slightly more expensive. There is no rollback; plan recovery as a copy.

Cross-course references

  • Kubernetes: CSI snapshots of CephFS subvolumes wrap this same mechanism
  • Linux: snapshot cost scales with the scope it covers, not with its count alone