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"];
  }

}

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

  • Snapshot 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;
  }
}

Volume-snapshot relation

  • When you create a snapshot snap1 of volume vol1, this volume becomes based on the snapshot.

  • vol1 contains only the changes since snap1 was 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 vol1 are recorded within the volume.

  • When there is a request for reading from vol1 the system reads data from the volume or from the parent snapshot snap1, 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;
  }
}

Volume-snapshot chain

  • snap1 contains a full image.

  • snap2 contains only the changes since snap1 was taken.

  • vol1 and vol2 contain only the changes since snap2 was 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"];
  }

}

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

}

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

}

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"];
  }

}

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

}

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

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

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

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

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

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

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

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

}

Using snapshots: example 2

There is one base image for Debian 13, three snapshot restore points, and one live volume custA.v.1

More information

Volumes and snapshots