6. Snapshot and Clone Applications¶
A snapshot is a reference marker for an application at a particular point in time. Snapshots are useful for example to instantaneously recover an application to a known healthy state in the event of corruption. Because snapshots capture a logical checkpoint of an application, they are also useful in backing up an application to an external storage repostitory, to enable clones of an application., etc. A clone is a copy of an application from one of its snapshots. Clones are useful when one wants to run a report on a database without affecting the source database application, or for performing UAT tests or for validating patches before applying them to the production database, etc.
Taking snapshots of storage volumes has existed for decades in the industry. However, when an application is distributed and/or uses multiple storage volumes across one or more pods, orchestrating storage-only snapshots across all of them is tedious, error prone and inconsistent. Storage-only snapshots are also unaware of the application configuration and its topology, which makes cloning, backing up or restoring cumbersome and prone to misconfiguration.
ROBIN allows creating application-consistent snapshots of an entire application, which captures:
The entire application topology and its configuration (i.e., specs of Pod, Service, StatefulSet, Secrets, ConfigMaps, etc), and
Snapshot of all data volumes (PersistentVolumeClaims)
ROBIN snapshots at the storage layer are based on Redirect-on-Write based technology, which means that snapshots can be taken in sub-seconds even for terabyte sized data volumes. Because only the changed blocks are tracked between snapshots, ROBIN snapshots are very space efficient.
Topics covered in this chapter:
|
Snapshot an entire application (data + metadata) |
|
Delete the snapshot of an application |
|
List snapshots for one or more applications |
|
Show detailed information about a specific snapshot |
|
Pushe snapshot to a repository (repo) attached to the application |
|
Pull a previously pushed snapshot from a repository (repo) |
|
Mark the snapshot as locked to prevent it from being deleted |
|
Unmark a previously locked snapshot, so that it can be deleted |
|
Show status of snapshot pull and push operations |
|
Clone an Application from its snapshot |
6.1. Creating an application snapshot¶
An application snapshot is created using the below command:
$ robin snapshot create <snapname> <appname>
|
A name that would be assigned to the snapshot being taken
|
|
Name of the application being snapshotted.
appname isobtained by running
robin app list command |
Before taking a snapshot all the Kubernetes resources (Pods, StatefulSets, PersistentVolumeClaims, etc) that constitute an application must be grouped together into an Application object (see Creating or Registering an Application).
Example: Snapshot a DataApp:
$ robin snapshot create snap1 mydb
$ robin snapshot list
+----------------------------------+--------+----------+----------+--------------------+
| Snapshot ID | State | App Name | App type | Snapshot name |
+----------------------------------+--------+----------+----------+--------------------+
| 8d2fa8145a4f11e9b59c2d26c7e69a00 | ONLINE | mysql-1 | helm | mysql-1_snap-mysql |
| 861bd41c5a4e11e9b18bf189ccf1d49b | ONLINE | mydb | helm | mydb_snap1 |
+----------------------------------+--------+----------+----------+--------------------+
6.1.1. Configuring snapshot schedules and retention policies¶
This is convered under Configuring Data Management Attributes of an Application section of Applications chapter. See details of command robin app config
.
6.2. Deleting an application snapshot¶
An application snapshot is deleted using the below command:
$ robin snapshot delete <snapid>
The id of a snapshot i.e. <snapid>
needs to be specified
|
Unique ID of the snapshot (this obtained from the output of
robin snapshot list ) |
Example::
$ robin snapshot delete 861bd41c5a4e11e9b18bf189ccf1d49b
$ robin snapshot list
+----------------------------------+--------+----------+----------+--------------------+
| Snapshot ID | State | App Name | App type | Snapshot name |
+----------------------------------+--------+----------+----------+--------------------+
| 8d2fa8145a4f11e9b59c2d26c7e69a00 | ONLINE | mysql-1 | helm | mysql-1_snap-mysql |
+----------------------------------+--------+----------+----------+--------------------+
6.3. List snapshots¶
Snapshots for applications in the users namespace are listed using the below command:
$ robin snapshot list [--app <appname>]
If --app <appname>
is specified, then only the snapshots of that ROBIN registered app are shown, else snapshots of all apps in the users namespace are listed.
Example 1: List snapshots of a specific app:
$ robin snapshot list --app mydb
+----------------------------------+--------+----------+----------+---------------+
| Snapshot ID | State | App Name | App type | Snapshot name |
+----------------------------------+--------+----------+----------+---------------+
| 861bd41c5a4e11e9b18bf189ccf1d49b | ONLINE | mydb | helm | mydb_snap1 |
+----------------------------------+--------+----------+----------+---------------+
Example 2: List all snapshots:
$ robin snapshot list
+----------------------------------+--------+----------+----------+--------------------+
| Snapshot ID | State | App Name | App type | Snapshot name |
+----------------------------------+--------+----------+----------+--------------------+
| 861bd41c5a4e11e9b18bf189ccf1d49b | ONLINE | mydb | helm | mydb_snap1 |
| 8d2fa8145a4f11e9b59c2d26c7e69a00 | ONLINE | mysql-1 | helm | mysql-1_snap-mysql |
+----------------------------------+--------+----------+----------+--------------------+
6.4. Show information about a specific snapshot¶
Details about a specific snapshot is obtained using the below command:
$ robin snapshot info <snapid>
The id of a snapshot i.e. <snapid>
needs to be specified
|
Unique ID of the snapshot (this obtained from the output of
robin snapshot list ) |
Example:
$ robin snapshot info 861bd41c5a4e11e9b18bf189ccf1d49b
Name : mydb_snap1
Id : 861bd41c5a4e11e9b18bf189ccf1d49b
Application Name : mydb
Application Kind : helm
State : ONLINE
Description :
Number of pvcs : 1
Number of backups : 0
Spec:
+-----------------------+--------------------------+
| Kind | Name |
+-----------------------+--------------------------+
| Secret | pgdb-postgresql |
| PersistentVolumeClaim | data-pgdb-postgresql-0 |
| Pod | pgdb-postgresql-0 |
| StatefulSet | pgdb-postgresql |
| Service | pgdb-postgresql-headless |
| Service | pgdb-postgresql |
+-----------------------+--------------------------+
PVCs:
+------------------------------------------+------+---------------+
| Name | Size | Snapshot Size |
+------------------------------------------+------+---------------+
| pvc-d1fbce5e-5a35-11e9-b48c-00155d61160c | 8G | - |
+------------------------------------------+------+---------------+
6.5. Push (Backup) a snapshot to an external storage repository¶
Pushing a snapshot to a storage repository would copy the app data + app metadata in that snapshot to the exteral storage repository (for example, S3, GCS, etc). Pushing a snapshot is the same as taking a backup of the application. A snapshot can be pushed using the below command:
$ robin snapshot push <name> <snapid> <reponame>
The id of a snapshot i.e. <snapid>
needs to be specified
|
Name of the resulting pushed snapshot.
|
|
Unique ID of the snapshot (this obtained from the output of
robin snapshot list ) |
|
Snapshot would be pushed to this storage repository. Before a snapshot is pushed,
a repo must be attached to the application (see
robin repo attach command).<reponame> is always required. |
Example:
$ robin snapshot push backup1 861bd41c5a4e11e9b18bf189ccf1d49b datadump
$ robin repo contents datadump --refresh
+----------------------------------+------------+---------+--------------------+
| BackupID | ZoneID | App | Snapshot |
+----------------------------------+------------+---------+--------------------+
| 5eccc5285a5211e9a1c3417886f14cc5 | 1554764031 | mydb | mydb_snap1 |
| a722a81e5a6811e9befabdcd54699900 | 1554764031 | mysql-1 | mysql-1_snap-mysql |
+----------------------------------+------------+---------+--------------------+
$ robin backup list
+----------------------------------+--------------+--------------------+--------+
| Backup ID | Backup Name | Snapshot Name | State |
+----------------------------------+--------------+--------------------+--------+
| 5eccc5285a5211e9a1c3417886f14cc5 | backup1 | mydb_snap1 | Pushed |
| a722a81e5a6811e9befabdcd54699900 | backup-mysql | mysql-1_snap-mysql | Pushed |
+----------------------------------+--------------+--------------------+--------+
6.6. Pull (Restore from backup) a snapshot from an external storage repository¶
A snapshot that has already been pushed to a repository can be pulled into ROBIN local storage. Pulling a snapshot from a repository is like restoring it from a backup copy that is residing in the repository. A snapshot is pulled using the below command:
$ robin snapshot pull <appname> <backupid>
|
Name of the ROBIN registered application that needs to be restored.
|
|
Unique ID for the snapshot within the repo. This is obtained when the snapshot
was pushed to the repo.
|
Example:
Verify the snapshot does not exist locally
$ robin snapshot list
+----------------------------------+--------+----------+----------+--------------------+
| Snapshot ID | State | App Name | App type | Snapshot name |
+----------------------------------+--------+----------+----------+--------------------+
+----------------------------------+--------+----------+----------+--------------------+
Restore the snapshot via:
$ robin snapshot pull mydb 5eccc5285a5211e9a1c3417886f14cc5
This will re-create a snapshot that was deleted locally earlier:
$ robin snapshot list
+----------------------------------+--------+----------+----------+--------------------+
| Snapshot ID | State | App Name | App type | Snapshot name |
+----------------------------------+--------+----------+----------+--------------------+
| 861bd41c5a4e11e9b18bf189ccf1d49b | ONLINE | mydb | helm | mydb_snap1 |
+----------------------------------+--------+----------+----------+--------------------+
6.7. Clone an Application¶
A clone is a copy of an existing application. Cloning is useful when you want to run reports on a database without affecting the source database application, or for performing UAT tests or for validating patches before applying them to the production database. Typically cloning an application requires significant manual or scripting work and coordination across the storage layer and the application metadata layer (Pod, StatefulSet, PVC, Service etc).
With ROBIN one can clone an entire application or application stack with one single command robin clone create
. Running this command creates a clone of an entire application from a previously taken application snapshot. Once complete the application is ready for use right away. Changes made to the clone are not visible in the parent application from which the clone was created. Similarly, any changes made to the parent application are not visible to the clone. At the storage layer, ROBIN Storage’s thin cloning technology is leveraged. Which means that a cloned PersistentVolume is not physical copy of the source volume, instead it is a virtual copy, where only metadata is physically copied with the actual data being shared between the clone and the source. Changes made to either the clone or the source are localized into their own “writable” data streams, whereas any common unmodified data is shared between them.
An application can be cloned using the following command:
$ robin clone create <clone-app-name> <snapshotid>
|
A name to give to the cloned application |
|
Snapshot ID of the source application. This is obtained by
running
robin snapshot list command |
Example:
$ robin clone copyofdb 861bd41c5a4e11e9b18bf189ccf1d49b
$ robin clone list
+----------+---------+-----------+-----------+---------+
| Name | Type | Namespace | Snapshots | Backups |
+----------+---------+-----------+-----------+---------+
| copyofdb | flexapp | default | 0 | 0 |
+----------+---------+-----------+-----------+---------+