6.1 Backing up and Restoring the Vertica Database

As a part of maintenance activities, taking regular backups of the Vertica database is recommended. Vertica provides the vbr utility that enables you to perform a full backup and restore operation of the Vertica database.

This utility enables you to perform the following operations:

  • Back up the database

  • Back up specific objects like schemas or tables, in a database.

  • Restore a database or individual objects from a backup.

  • Copy a database to another cluster. For example, to promote a test cluster to production (for Enterprise mode only). For more information, see Vertica Documentation.

  • Replicate individual objects such as schemas and tables to another cluster (for Enterprise mode only). For more information, see Vertica Documentation.

  • List available backups.

The topics addressed in this section are:

6.1.1 Creating Configuration File for Vertica Full Local Backup

To run the vbr utility, you need to specify a configuration file that contains information such as the backup location, name of the database and dbuser, the snapshot name, db administrator password file path, and retry count. Vertica provides a few sample configuration files available at /opt/vertica/share/vbr/example_configs/backup_restore_full_local.ini that can be used for various vbr tasks.

If the dbPromptForPassword parameter in the configuration file is true, then the vbr utility will prompt for a password every time you run the utility. However, to avoid user intervention while performing the backup operation, you can specify the location of the db administrator password config file in the passwordFile parameter. For example, passwordFile=/path/to/vbr/pw.txt. This file should be read protected by the db administrator user only. The format of the content in the pw.txt file should be:

[Passwords]

dbPassword=******

For more information on creating the configuration file, see the Vertica Documentation.

6.1.2 Creating a Full Local Backup

Prerequisites

  • Ensure that you initialize the backup location by running the following command vbr -t init -c full-backup.ini.

  • Your database should be up and running. All nodes need not be in a K-safe database. However, the nodes that are down are not backed up.

  • All of the backup hosts should be up and running.

  • Enough disk space should be available to store the backups.

  • The user account of the user who starts the vbr utility should have write access to the target directories on the host backup location. This user can be dbadmin or another assigned role. However, you cannot run the vbr utility as root.

  • Each backup has a unique file name. If you want to keep earlier backups, ensure that the restorePointLimit parameter is set to a number greater than 1 in the configuration file

Procedure

Run the vbr utility from a terminal. Use the database administrator account from an initiator node in the database cluster.

Run the following command and a backup will be created without any further intervention:

vbr -t backup -c full-backup.ini

6.1.3 Restoring from a backup

Prerequisites

Before performing a full restore from the backed up database, ensure that the following requirements are met:

  • The database is down. You cannot perform the restore action when the database is running.

  • All the backup hosts are available.

  • The backup directory exists and contains the backups from which to restore the data.

  • The cluster to which you are restoring the backup should have:

    • The same number of nodes as the one used to create the backup.

    • The same architecture (Enterprise or Eon mode) as the one used to create the backup.

    • Identical node names.

Procedure

To restore from the most recent backup, run the following command:

vbr -t restore -c full-backup.ini

To restore an archived backup, add the --archive parameter to the command line along with the directory name, which is the date_timestamp that identifies the archive to restore. For example, vbr -t restore -c full-backup.ini --archive=20190712_085620. This will restore from the archive created on 12th July 2019 and 8:56:20.