Backing Up KVLocal Store
Using snapshots you can make backups of your KVLocal store to copy its data and configurations. Later, you can restore KVLocal store data and configurations from a snapshot.
Method Name | Description | Parameter(s) | Returns |
---|---|---|---|
String createSnapshot(String name) | Creates a new snapshot using the specified name as a suffix.
This method backs up the data files and configuration files of the KVLocal store, including files required for restore activities. The snapshot data is stored in a directory inside the kvroot directory. Note: When you create a snapshot, it is stored in a subdirectory of the host machine. But these snapshots don't become persistent backups unless they are copied to separate storage. It is your responsibility to copy each of the snapshots to another location, preferably on a different machine, for data safety. |
name - specifies the suffix to use for the snapshot name. | The generated snapshot name. The generated snapshot name has a date-time prefix. The date-time prefix consists of a 6-digit, year, month, day value in YYMMDD format, and a 6-digit hour, minute, seconds timestamp as HHMMSS. The date and time values are separated from each other with a dash (-) and include a dash (-) suffix before the input snapshot name.
Example: If you specify |
KVLocal restoreFromSnapshot(String rootDir, String name) | Restores the store from a snapshot.
This method replaces the data in the |
rootDir - specifies the root directory of the store.
name - specifies the name of the snapshot, including the date and time that was generated by createSnapshot API. |
An instance of KVLocal. |
void removeSnapshot(String name) | Removes a snapshot.
Tip: To preserve storage, you should periodically remove obsolete snapshots. |
name - specifies the full name of the snapshot, including date and time, that was generated by the createSnapshot API. | |
String[] listSnapshots() | Lists the names of all the snapshots. | An array of names of snapshots. |
import oracle.kv.KVLocalConfig;
import oracle.kv.KVLocal;
/* Start the KVLocal */
KVLocalConfig config = new KVLocalConfig.InetBuilder("/home/kvstore").build();
KVLocal local = KVLocal.start(config);
/* Create a Snapshot */
String snapshotName = local.createSnapshot("sp1");
/* List all Snapshots */
String snapshotName = local.listSnapshots();
/* Stop the KVLocal */
local.stop();
/* Restore from a Snapshot */
local = KVLocal.restoreFromSnapshot(rootDir,snapshotName);
import oracle.kv.KVLocalConfig;
import oracle.kv.KVLocal;
/* Start the KVLocal */
KVLocalConfig config = new KVLocalConfig.UnixDomainBuilder("/home/kvstore").build();
KVLocal local = KVLocal.start(config);
/* Create a Snapshot */
String snapshotName = local.createSnapshot("sp1");
/* List all Snapshots */
String snapshotName = local.listSnapshots();
/* Stop the KVLocal */
local.stop();
/* Restore from a Snapshot */
local = KVLocal.restoreFromSnapshot(rootDir,snapshotName);