Snapshots
Snapshots are read-only point-in-time images of volumes (see Volumes).
They are created once and their data cannot be modified.
They can be attached to hosts as read-only block devices under /dev/storpool.
![digraph G {
rankdir=TD;
compound=true;
ranksep=1;
image=svg;
subgraph cluster_0 {
shape="square";
style="filled";
color="black";
fillcolor="lightgrey:white";
gradientangle=90;
node [style=filled,color=black,fillcolor=white];
a1 [shape="ellipse",label="snap1"];
}
}](../_images/graphviz-af0d3a7f0d1fd52add649266f5a5e5f60b9c5c07.png)
A single snapshot
Introduction
All volumes and snapshots share the same name-space. Names of volumes and snapshots are unique within a StorPool cluster. This means you can’t have a volume and a snapshot with the same name. Here is a simple example with unique names:
Volume names:
vol1,vol2,vol3Snapshot names:
snap1,snap2,snap3
This diagram illustrates the relationship between a snapshot and a volume:
![digraph G {
rankdir=TB;
image=svg;
compound=true;
subgraph cluster_0 {
shape="square";
style=filled;
color=black;
fillcolor="lightgrey:white";
gradientangle=90;
node [style=filled,color=black,fillcolor=white];
snap1 [shape="ellipse",label="snap1"];
vol1 [shape="box",label="vol1"];
snap1 -> vol1;
}
}](../_images/graphviz-ecad44044a1cc25915aede49bf46b07db56896d8.png)
Volume-snapshot relation
When you create a snapshot
snap1of volumevol1, this volume becomes based on the snapshot.vol1contains only the changes sincesnap1was taken. In the common case this is a small amount of data.Arrows indicate a child-parent relationship. Each volume or snapshot may have exactly one parent which it is based upon.
Writes to
vol1are recorded within the volume.When there is a request for reading from
vol1the system reads data from the volume or from the parent snapshotsnap1, depending on whether the data has been changed since the snapshot was created.
Snapshots and volumes are completely independent. Each snapshot may have many children (volumes and snapshots). Volumes cannot have children. This is illustrated in the diagram below:
![digraph G {
rankdir=TB;
image=svg;
compound=true;
subgraph cluster_0 {
shape="box";
style=filled;
color=black;
fillcolor="lightgrey:white";
gradientangle=90;
node [style=filled,color=black,fillcolor=white];
snap1 [shape="ellipse",label="snap1"];
snap2 [shape="ellipse",label="snap2"];
vol1 [shape="box",label="vol1"];
vol2 [shape="box",label="vol2"];
snap1 -> snap2;
snap2 -> vol1;
snap2 -> vol2;
}
}](../_images/graphviz-f473d1543d2bad3701742a6726541dfc2efae0a2.png)
Volume-snapshot chain
snap1contains a full image.snap2contains only the changes sincesnap1was taken.vol1andvol2contain only the changes sincesnap2was taken.
Creating a snapshot of a volume
Assume there is a volume named vol1.
![digraph G {
rankdir=TD;
compound=true;
ranksep=1;
image=svg;
subgraph cluster_step_0 {
shape="box";
style="filled";
color="black";
fillcolor="lightgrey:white";
gradientangle=90;
node [style=filled,color=black,fillcolor=white];
a1 [shape="box",label="vol1"];
}
}](../_images/graphviz-5f8c1876326852c88acd7d81fba4e86ed46f24c0.png)
A single volume
After the first snapshot the state of vol1 is recorded in a new snapshot
named snap1. vol1 does not occupy any space now, but will record any new
writes which come in after the creation of the snapshot. Reads from vol1 may
fall through to snap1.
![digraph G {
rankdir=TD;
compound=true;
ranksep=0.5;
image=svg;
subgraph cluster_step_1 {
shape="box";
style="filled";
color="black";
fillcolor="lightgrey:white";
gradientangle=90;
node [style=filled,color=black,fillcolor=white];
b1 [shape="ellipse",label="snap1"];
b2 [shape="box",label="vol1"];
b1 -> b2;
}
}](../_images/graphviz-60af8cd752e577a0ae1b23eebf7de6a447ab5cfb.png)
After the first snapshot
Here is an example how you can create a snapshot using the CLI (see Creating snapshots):
# storpool volume vol1 snapshot snap1
You can create more snapshots, as shown in the example below.
The state of vol1 is recorded in a new snapshot named snap2.
snap2 contains the changes between the moment snap1 was taken and the
moment snap2 was taken. snap2’s parent is the original parent of
vol1.
![digraph G {
rankdir=TD;
compound=true;
ranksep=0.5;
image=svg;
subgraph cluster_step_2 {
shape="box";
style="filled";
color="black";
fillcolor="lightgrey:white";
gradientangle=90;
node [style=filled,color=black,fillcolor=white];
c1 [shape="ellipse",label="snap1"];
c2 [shape="ellipse",label="snap2"];
c3 [shape="box",label="vol1"];
c1 -> c2;
c2 -> c3;
}
}](../_images/graphviz-4d257ed5911f51ab9573a53d8fc46e6c65375bb8.png)
After the second snapshot
You can do this on the CLI using the same command, just set a different name for the next snapshot:
# storpool volume vol1 snapshot snap2
Creating a volume based on an existing snapshot (cloning)
Before the creation of volume there is a snapshot named snap1.
![digraph G {
rankdir=TD;
compound=true;
ranksep=1;
image=svg;
subgraph cluster_0 {
shape="square";
style="filled";
color="black";
fillcolor="lightgrey:white";
gradientangle=90;
node [style=filled,color=black,fillcolor=white];
a1 [shape="ellipse",label="snap1"];
}
}](../_images/graphviz-af0d3a7f0d1fd52add649266f5a5e5f60b9c5c07.png)
A single snapshot
A new vol1 volume is created, which is based on the snap1 snapshot. The
newly created volume does not occupy any space initially. Reads from the
vol1 may fall through to snap1 or to snap1’s parents (if any).
![digraph G {
rankdir=TD;
compound=true;
ranksep=0.5;
image=svg;
subgraph cluster_0 {
shape="box";
style="filled";
color="black";
fillcolor="lightgrey:white";
gradientangle=90;
node [style=filled,color=black,fillcolor=white];
snap1 [shape="ellipse",label="snap1"];
vol1 [shape="box",label="vol1"];
snap1 -> vol1;
}
}](../_images/graphviz-4a88eb506fb61c6926c39cacbeb2093af126964e.png)
Volume created from a snapshot
Here is an example how you can create a volume based on an existing snapshot using the CLI (see Volume operations):
# storpool volume vol1 parent snap1
Deleting a snapshot
The vol1 and vol2 volumes are based on the snap1 snapshot. snap1 is based on snap0.
snap1 contains the changes between the moment snap0 was taken and when
snap1 was taken. vol1 and vol2 contain the changes since the moment
snap1 was taken.
![digraph G {
rankdir=TB;
image=svg;
compound=true;
subgraph cluster_0 {
shape="box";
style=filled;
color=black;
fillcolor="lightgrey:white";
gradientangle=90;
node [style=filled,color=black,fillcolor=white];
snap0 [shape="ellipse",label="snap0"];
snap1 [shape="ellipse",label="snap1"];
vol1 [shape="box",label="vol1"];
vol2 [shape="box",label="vol2"];
snap0 -> snap1;
snap1 -> vol1;
snap1 -> vol2;
}
}](../_images/graphviz-24b21fe85d8bc08e10c779d6cb62e6279d486fae.png)
Before deletion
After the deletion of the snap1 snapshot, vol1 and vol2 are based on snap1’s original
parent (if any). In the example here they are now based on snap0. When deleting a
snapshot, the changes contained therein will not be propagated to its children
and StorPool will keep the snap1 in deleting state to prevent from an
explosion of disk space usage.
![digraph G {
rankdir=TB;
image=svg;
compound=true;
subgraph cluster_0 {
shape="box";
style=filled;
color=black;
fillcolor="lightgrey:white";
gradientangle=90;
node [style=filled,color=black,fillcolor=white];
snap0 [shape="ellipse",label="snap0"];
vol1 [shape="box",label="vol1"];
vol2 [shape="box",label="vol2"];
snap0 -> vol1;
snap0 -> vol2;
}
}](../_images/graphviz-213736616fc5a4c2d7e677957823d0254ed82bd0.png)
After deletion
Here is an example how you can delete a snapshot using the CLI (see Deleting snapshots):
# storpool snapshot snap1 delete snap1
Rebasing snapshots
For details on how rebasing works on the command line, see Promoting snapshots.
Rebasing to null (promoting a snapshot)
The vol1 volume is based on the snapshots from snap0 to snap3 (see the diagram below).
vol1 contains the changes since the moment snap3 was taken.
![digraph G {
rankdir=TB;
image=svg;
ranksep=0.5;
compound=true;
subgraph cluster_0 {
shape="box";
style=filled;
color=black;
fillcolor="lightgrey:white";
gradientangle=90;
node [style=filled,color=black,fillcolor=white];
snap0 [shape="ellipse",label="snap0"];
snap1 [shape="ellipse",label="snap1"];
snap2 [shape="ellipse",label="snap2"];
snap3 [shape="ellipse",label="snap3"];
vol1 [shape="box",label="vol1"];
snap0 -> snap1;
snap1 -> snap2;
snap2 -> snap3;
snap3 -> vol1;
}
}](../_images/graphviz-851b0b6a35ccff55dd30b6211d70562aa4e17ab8.png)
Before rebase to null
After promotion the snap3 snapshot is not based on another snapshot.
It now contains all the changes from snap0 to snap2.
vol1 is still based on snap3, and contains the changes since the moment snap3 was taken.
![digraph G {
rankdir=TB;
image=svg;
ranksep=0.5;
compound=true;
subgraph cluster_0 {
shape="box";
style=filled;
color=black;
fillcolor="lightgrey:white";
gradientangle=90;
node [style=filled,color=black,fillcolor=white];
snap0 [shape="ellipse",label="snap0"];
snap1 [shape="ellipse",label="snap1"];
snap2 [shape="ellipse",label="snap2"];
snap3 [shape="ellipse",label="snap3"];
vol1 [shape="box",label="vol1"];
snap0 -> snap1;
snap1 -> snap2;
snap3 -> vol1;
}
}](../_images/graphviz-452319f51bf2a1295eadb2df9c3cb4622bd3f3a8.png)
After rebase to null
Here is an example how you can promote a snapshot using the CLI:
# storpool snapshot snap3 rebase
Rebasing a snapshot to another snapshot
The vol1 volume is based on the snapshots from snap0 to snap3 (see the diagram below).
vol1 contains the changes since the moment snap3 was taken.
![digraph G {
rankdir=TB;
image=svg;
ranksep=0.5;
compound=true;
subgraph cluster_0 {
shape="box";
style=filled;
color=black;
fillcolor="lightgrey:white";
gradientangle=90;
node [style=filled,color=black,fillcolor=white];
snap0 [shape="ellipse",label="snap0"];
snap1 [shape="ellipse",label="snap1"];
snap2 [shape="ellipse",label="snap2"];
snap3 [shape="ellipse",label="snap3"];
vol1 [shape="box",label="vol1"];
snap0 -> snap1;
snap1 -> snap2;
snap2 -> snap3;
snap3 -> vol1;
}
}](../_images/graphviz-851b0b6a35ccff55dd30b6211d70562aa4e17ab8.png)
Before rebase
After rebasing the snap3 snapshot is based on the snap0 snapshot.
It now contains also the changes from snap1 and snap2.
vol1 is still based on snap3, and contains the changes since the moment snap3 was taken.
![digraph G {
rankdir=TB;
image=svg;
ranksep=0.5;
compound=true;
subgraph cluster_0 {
shape="box";
style=filled;
color=black;
fillcolor="lightgrey:white";
gradientangle=90;
node [style=filled,color=black,fillcolor=white];
snap0 [shape="ellipse",label="snap0"];
snap1 [shape="ellipse",label="snap1"];
snap2 [shape="ellipse",label="snap2"];
snap3 [shape="ellipse",label="snap3"];
vol1 [shape="box",label="vol1"];
snap0 -> snap1;
snap1 -> snap2;
snap0 -> snap3;
snap3 -> vol1;
}
}](../_images/graphviz-ea7ce515bdc2805809b17359a76338622195f2ab.png)
After rebase
Here is an example how you can rebase a snapshot using the CLI:
# storpool snapshot snap3 rebase snap0
Example use of snapshots
This is a semi-realistic example of how volumes and snapshots may be used:
![digraph G {
rankdir=TB;
image=svg;
ranksep=0.5;
compound=true;
subgraph cluster_0 {
shape="box";
style=filled;
color=black;
fillcolor="lightgrey:white";
gradientangle=90;
node [style=filled,color=black,fillcolor=white];
snapbase [shape="ellipse",label="base.\ndebian13"];
cluster_customer_1 [shape="rectangle",label="Customer A:\n- Volume 1\n- Volume 2\n- Volume 3\n- Volume 4",fillcolor="lightgrey:white",gradientangle=90;];
cluster_customer_2 [shape="rectangle",label="Customer B:\n- Volume 1\n- Volume 2\n- Volume 3\n- Volume 4",fillcolor="lightgrey:white",gradientangle=90;];
cluster_customer_3 [shape="rectangle",label="Customer C:\n- Volume 1\n- Volume 2\n- Volume 3\n- Volume 4",fillcolor="lightgrey:white",gradientangle=90;];
snapbase -> cluster_customer_1;
snapbase -> cluster_customer_2;
snapbase -> cluster_customer_3;
}
}](../_images/graphviz-6ed3d26e3aacb6eb0f997d2438b81242dd881351.png)
Using snapshots: example 1
There is a snapshot called
base.debian13. This snapshot contains a base VM image (in this example, Debian 13), which was prepared carefully by the service provider.There are 3 customers with 4 virtual machines each.
All virtual machine images are based on the same ‘master’ image, but may contain custom data, which is unique to each VM. Changes in one volume don’t affect the parent snapshots or the other volumes that are created from it.
This example shows another typical use of snapshots - for restore points back in time for a volume.
![digraph G {
rankdir=TB;
image=svg;
ranksep=0.5;
compound=true;
subgraph cluster_restore_points {
shape="box";
style=filled;
color=black;
fillcolor="lightgrey:white";
gradientangle=90;
node [style=filled,color=black,fillcolor=white];
base [shape="ellipse",label="base.debian13"];
snap1 [shape="ellipse",label="custA.v1.last_week"];
snap2 [shape="ellipse",label="custA.v1.20240221"];
snap3 [shape="ellipse",label="custA.v1.20240222"];
vol1 [shape="box",label="custA.v1"];
base -> snap1 -> snap2 -> snap3 -> vol1;
}
}](../_images/graphviz-9a5eca098426e44350491446e29f99c112bcf0fb.png)
Using snapshots: example 2
There is one base image for Debian 13, three snapshot
restore points, and one live volume custA.v.1