Version:

Backing Up/Restoring Kinetica

KAgent can be used to simplify the processes of backing up and restoring the Kinetica database. It is distributed separately from the database and can be installed and used to configure a Kinetica cluster following the instructions under Kinetica Installation with KAgent (On Premise).

Prerequisites

KAgent backup management has two requirements:

  • KAgent installed, with access to the cluster being managed
  • A properly configured Kinetica cluster

Note

Kinetica does not need to be offline to be backed up or restored.

Backing Up

All the data in Kinetica can be backed up in either an ad-hoc or scheduled fashion, using the command line. To learn about how to back up Kinetica using the KAgent GUI, consult Backups.

Backups are stored local to each node in the cluster. Those local backup file target directories can be mounted via NFS or similar external shared storage to consolidate those files to a single device.

The base command for creating a backup:

/opt/gpudb/kagent/bin/kagent cluster backup [--schedule <schedule>] [--backup-path <backup-path>] <cluster-name>

Tip

To list the backup schedule for the cluster:

/opt/gpudb/kagent/bin/kagent cluster backup --list-schedule ALL <cluster-name>

Schedule

There are three options for schedule:

  • now -- Runs a single backup right now without creating or modifying the schedule; (default behavior)

  • A crontab schedule quoted string -- Will overwrite any existing backup schedule with the one specified.

    For example, '0 0 1 1-3 *' will schedule backups at 12:00 AM on the 1st day of each month, January through March.

    Consult the crontab documentation for details on schedule specification format.

  • never -- Clears the current backup schedule for the given cluster name

Backup Path

The backup path should be any valid file path on the KAgent-hosting node. If the directory does not exist, KAgent will create it.

The default backup path is /opt/backups.

Under this backup path directory, KAgent will create a subdirectory with the name of the cluster as the directory name. KAgent will then create a snapshot subdirectory under the cluster-specific subdirectory, named with the date/time at which the backup was initiated, into which all backup files will be placed.

For instance, given the following backup command execution, run at 12:34:56 on January 2nd, 2019:

/opt/gpudb/kagent/bin/kagent cluster backup mycluster

Backup files will be placed under this location:

/opt/backups/mycluster/snapshot.2019-01-02.12-34-56

Examples

To list backups scheduled for the mycluster cluster:

/opt/gpudb/kagent/bin/kagent cluster backup --list-schedule ALL mycluster

To create an immediate backup of the mycluster cluster in the (default) /opt/backups directory:

/opt/gpudb/kagent/bin/kagent cluster backup mycluster

To create a backup in /tmp/kinetica-backups/ for the cluster named mainkincluster scheduled for 22:00 on day 1 through 5 of every week:

/opt/gpudb/kagent/bin/kagent cluster backup --schedule '0 22 * * 1-5' --backup-path /tmp/kinetica-backups/ mainkincluster

To remove the backup scheduled for the mycluster cluster:

/opt/gpudb/kagent/bin/kagent cluster backup --schedule never mycluster

Restoring

Backups made through KAgent are restored through KAgent, either via command line or the KAgent GUI. See Snapshots for details on restoring from snapshots using the GUI.

The base command for restoring from backup:

/opt/gpudb/kagent/bin/kagent cluster restore --restore-from <snapshot-name> [--backup-path <backup-path>] <cluster-name>

Tip

To list all backups for the cluster:

/opt/gpudb/kagent/bin/kagent cluster list-backups [--backup-path <backup-path>] <cluster-name>

For example, running this command:

/opt/gpudb/kagent/bin/kagent cluster list-backups mycluster

Might show output like this, for cluster snapshots under /opt/backups:

/mycluster/snapshot.2019-01-02.01-23-45
/mycluster/snapshot.2019-01-02.12-34-56

Restore From

The --restore-from parameter specifies which backup snapshot should be restored. It should be the path to the existing snapshot to restore from, including the cluster directory above it:

<cluster name>/snapshot.<date>.<time>

Backup Path

The backup path should be the file path on the KAgent-hosting node that contains the backups to restore.

The default backup path is /opt/backups.

KAgent will look in the directory given in the --restore-from parameter for the directory named in the --backup-path parameter. If found, KAgent will restore the database from that snapshot.

For instance, given the following restore command execution:

/opt/gpudb/kagent/bin/kagent cluster restore --restore-from mycluster/snapshot.2019-01-02.12-34-56 mycluster

A backup snapshot directory will be looked for at this location:

/opt/backups/mycluster/snapshot.2019-01-02.12-34-56

Examples

To list backups for the mycluster cluster:

/opt/gpudb/kagent/bin/kagent cluster list-backups mycluster

To restore a backup of the mycluster cluster in the (default) /opt/backups directory that was initiated on January 2nd, 2019 at 12:34:56:

/opt/gpudb/kagent/bin/kagent cluster restore --restore-from mycluster/snapshot.2019-01-02.12-34-56 mycluster

To restore a backup in /tmp/kinetica-backups/ for the cluster named mainkincluster that was initiated on January 2nd, 2019 at 01:23:45:

/opt/gpudb/kagent/bin/kagent cluster restore --restore-from mainkincluster/snapshot.2019-01-02.01-23-34 --backup-path /tmp/kinetica-backups/ mainkincluster

Deleting Backups

Backups can be deleted manually from their location in the cluster's snapshot directory.

The command for deleting a backup:

rm -rf <backup-path>/<cluster-name>/<snapshot-name>

For example, to delete a backup of the mycluster cluster in the /opt/backups directory that was initiated on January 2nd, 2019 at 12:34:56:

rm -rf /opt/backups/mycluster/snapshot.2019-01-02.12-34-56

Tip

To list all backups for the cluster:

/opt/gpudb/kagent/bin/kagent cluster list-backups [--backup-path <backup-path>] <cluster-name>

For example, running this command:

/opt/gpudb/kagent/bin/kagent cluster list-backups mycluster

Might show output like this, for cluster snapshots under /opt/backups:

/mycluster/snapshot.2019-01-02.01-23-45
/mycluster/snapshot.2019-01-02.12-34-56

From there, the backup path (/opt/backups, in this case), can be prepended to any of these directories and a recursive file deletion applied to remove them.