Skip to main content
Version: 5.11.0

Snapshots

LeilFS supports instant, space‑efficient snapshots using copy‑on‑write (COW) semantics. Snapshots are created at the filesystem level from any mounted client and do not require separate snapshot volumes or pre‑allocated space.


Creating snapshots

Use leil makesnapshot to snapshot a file or a directory tree. The command takes one or more sources and a single destination:

leil makesnapshot SOURCE... DESTINATION
# Snapshot a directory
leil makesnapshot /mnt/client/production /mnt/client/snapshots/prod_2026-03-19

# Snapshot a single file
leil makesnapshot /mnt/client/db/data.img /mnt/client/db/data.img.bak

Both the source and the destination must live inside the same LeilFS mount.

By default leil makesnapshot refuses to overwrite an existing destination. Pass -o (overwrite) to replace an existing target:

leil makesnapshot -o /mnt/client/production /mnt/client/snapshots/latest

How snapshots work

When a snapshot is created, LeilFS adds new directory entries that point to the same chunk objects as the source. No data is copied at snapshot time, so the operation is instant and consumes no additional storage.

Chunks are only duplicated when one of the references is modified — this is the copy‑on‑write step. Until a chunk diverges, the snapshot and the original share it. As a result:

  • Creating a snapshot is O(metadata), not O(data).
  • A snapshot consumes extra space only in proportion to how much the data changes after the snapshot is taken.
note

Snapshots follow the goal of the object they point to. Newly written (diverged) chunks are stored according to the goal in effect at write time. See Replication for how goals control the number of copies and erasure coding.


Snapshots and the trash

Snapshots are independent of the trash system. Deleting a file moves it to the trash for its configured trashtime, but a snapshot is a normal set of directory entries — it does not expire and is not removed automatically.

caution

Snapshots must be deleted explicitly when they are no longer needed. Because they never expire on their own, include snapshot cleanup in your data‑retention policy or old snapshots will keep diverged chunks alive indefinitely.


Quick reference

TaskCommand
Snapshot a file or directoryleil makesnapshot SOURCE DESTINATION
Overwrite an existing snapshotleil makesnapshot -o SOURCE DESTINATION
Inspect chunks of a snapshotleil fileinfo DESTINATION

See the CLI reference for the full command set.