Network Backups
Overview
GridGain provided a way to create network backups, allowing you to back up your cluster data to a network location such as NAS or NFS for recovery purposes. Since the data is stored on a different physical device, network backups provide security against disk failures. The network location is used as a centralized storage where all cluster nodes can save data and then use it for recovery. Using centralized storage also lets you restore the cluster to a different physical location or even in the cloud.
Prerequisites
-
Snapshot functionality has to be enabled. Please refer to Snapshots & Recovery for instructions.
-
The centralized storage has to be mounted to all machines hosting the cluster nodes and have the same path.
Creating Network Backup
There are two ways to create a network backup:
-
Create a local (regular) snapshot and move it to a shared folder.
-
Create a snapshot directly into a shared folder.
These two approaches are discussed below.
Saving Snapshots Directly to Centralized Storage
You can tell GridGain to create a snapshot directly into the centralized storage by specifying a path:
snapshot-utility.sh snapshot -type=full -dest=/shared/folder
// Get a reference to GridGain plugin.
GridGain gg = ignite.plugin(GridGain.PLUGIN_NAME);
// Get a reference to the Snapshots.
GridSnapshot storage = gg.snapshot();
// Create the snapshot. Data of all the caches will be added to the snapshot.
GridSnapshotFuture snapshotFuture = storage.createFullSnapshot(null, new File("/shared/folder/path/"), "Snapshot has been created!");
// Wait while the snapshot is being done.
snapshotFuture.get()
Moving Snapshots to Centralized Storage
If you do not specify a snapshot location when creating a snapshot, each node will save its data to a local folder. In this case, the snapshot is stored on local drives of the cluster nodes. To move the data to a centralized storage, use either the move
command of the Snapshots Management Tool or the Java API.
snapshot-utility.sh move -id=123456 -dest=/shared/folder
// Get a reference to GridGain plugin.
GridGain gg = ignite.plugin(GridGain.PLUGIN_NAME);
// Get a reference to the Snapshots.
GridSnapshot snapshot = gg.snapshot();
// Get the first snapshot from the list.
SnapshotInfo info = snapshot.listSnapshots(null).get(0);
// Get the snapshot ID.
long snapshotId = info.snapshotId();
// Move the snapshot with given ID to a shared folder.
SnapshotFuture<Void> future = snapshot.moveSnapshot(snapshotId, new File("/shared/folder/path"), "Snapshot Moved");
// Wait for the operation to finish.
future.get();
var ignite = Ignition.Start(cfg);
// Get a reference to grid snapshot API.
var snapshot = ignite.GetSnapshot();
// Get the first snapshot from the list.
var en = snapshot.GetSnapshots(null).GetEnumerator();
en.MoveNext();
var info = en.Current;
// Get the snapshot ID.
long snapshotId = info.SnapshotId;
// Move the snapshot with given ID to a shared folder.
var task = snapshot.MoveSnapshotAsync(snapshotId, "/shared/folder/path", "Snapshot Moved");
// Wait for the operation to finish.
task.Task.Wait();
Restoring from Network Backup
To restore a cluster from a network backup, use the centralized storage as a snapshot location:
snapshot-utility.sh restore -id=123456 -src=/shared/folder/path
// Get a reference to GridGain plugin.
GridGain gg = ignite.plugin(GridGain.PLUGIN_NAME);
// Get a reference to GridSnapshot.
GridSnapshot storage = gg.snapshot();
// Get the first snapshot from the list.
GridSnapshotOperation info = storage.listSnapshots(null).get(0);
// Get the snapshot ID.
long snapshotId = info.snapshotId();
// Replace content of all the caches with the content from the snapshot.
IgniteFuture<Void> future = storage.restoreSnapshot(snapshotId, null, Collections.singleton("/shared/folder/path"), "Cluster Restored!");
// Wait until the operation finishes.
future.get();
var ignite = Ignition.Start(cfg);
// Get a reference to grid snapshot API.
var snapshot = ignite.GetSnapshot();
// Get the first snapshot from the list.
var en = snapshot.GetSnapshots(null).GetEnumerator();
en.MoveNext();
var info = en.Current;
// Get the snapshot ID.
long snapshotId = info.SnapshotId;
// Replace content of all the caches with the content from the snapshot.
var task = snapshot.RestoreSnapshotAsync(snapshotId, new[] { "/shared/folder/path" }, null, "Cluster Restored!");
// Wait for the operation to finish.
task.Task.Wait();
Each node will compute which partitions belong to the local node and restore corresponding partitions from the centralized storage to the local storage.
© 2020 GridGain Systems, Inc. All Rights Reserved. Privacy Policy | Legal Notices. GridGain® is a registered trademark of GridGain Systems, Inc.
Apache, Apache Ignite, the Apache feather and the Apache Ignite logo are either registered trademarks or trademarks of The Apache Software Foundation.