> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Backup and Restore Overview

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

This page provides an overview of the backup and restore features available in CockroachDB:

* [Types of backup available in CockroachDB](#cockroachdb-backup-types)
* [Backup and restore product support](#backup-and-restore-product-support)
* [Schedules](#scheduled-backups) for periodic backups
* [SQL statements](#backup-and-restore-sql-statements) for working with backups and restores
* [Storage](#backup-storage) for backups

You can create full or incremental backups of a <InternalLink path="backup#back-up-a-cluster">cluster</InternalLink>, <InternalLink path="backup#back-up-a-database">database</InternalLink>, or <InternalLink path="backup#back-up-a-table-or-view">table</InternalLink>. Taking regular backups of your data is an operational best practice.

For an explanation of how a backup works, see <InternalLink path="backup-architecture">Backup Architecture</InternalLink>.

## CockroachDB backup types

CockroachDB supports two types of backups:

* **Managed backups**: Cockroach Labs takes automated backups of CockroachDB Cloud clusters that are stored in Cockroach Labs' cloud storage.  Refer to <InternalLink version="cockroachcloud" path="managed-backups">Managed Backups</InternalLink> to learn more about the type and frequency of backups supported for both CockroachDB Cloud clusters.
* **Self-managed backups**:  **<InternalLink version="cockroachcloud" path="take-and-restore-self-managed-backups">Self-managed backups</InternalLink>**:  You can take manual backups and store them in your <InternalLink path="use-cloud-storage">cloud storage buckets</InternalLink> using the <InternalLink path="backup">`BACKUP`</InternalLink> statement. Self-managed backups are supported in all CockroachDB  plans and CockroachDB self-hosted.

## Backup and restore product support

This table outlines the level of product support for backup and restore features in CockroachDB. See each of the pages linked in the table for usage examples:

| Backup / Restore                                                                                                                      | Description                                                                                                                                                  | Product Support                                                                                                                                                                                                                                                     |
| ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <InternalLink path="take-full-and-incremental-backups">Full backup</InternalLink>                                                     | An un-replicated copy of your cluster, database, or table's data. A full backup is the base for any further backups.                                         | <ul><li>All products</li><ul /></ul>                                                                                                                                                                                                                                |
| <InternalLink path="take-full-and-incremental-backups">Incremental backup</InternalLink>                                              | A copy of the changes in your data since the specified base backup (either a full backup or a full backup plus an incremental backup).                       | <ul><li>CockroachDB Standard and CockroachDB Basic — self-managed backups</li><li>CockroachDB Advanced — managed backups and self-managed backups</li><li>CockroachDB with an <InternalLink path="licensing-faqs">Enterprise license</InternalLink></li><ul /></ul> |
| <InternalLink path="manage-a-backup-schedule">Scheduled backup</InternalLink>                                                         | A schedule for periodic backups.                                                                                                                             | <ul><li>CockroachDB Standard and CockroachDB Basic — self-managed backups</li><li>CockroachDB Advanced — self-managed backups</li><li>CockroachDB with an <InternalLink path="licensing-faqs">Enterprise license</InternalLink></li><ul /></ul>                     |
| <InternalLink path="take-backups-with-revision-history-and-restore-from-a-point-in-time">Backups with revision history</InternalLink> | A backup with revision history allows you to back up every change made within the garbage collection period leading up to and including the given timestamp. | <ul><li>CockroachDB Standard and CockroachDB Basic — self-managed backups</li><li>CockroachDB Advanced — self-managed backups</li><li>CockroachDB with an <InternalLink path="licensing-faqs">Enterprise license</InternalLink></li><ul /></ul>                     |
| <InternalLink path="take-backups-with-revision-history-and-restore-from-a-point-in-time">Point-in-time restore</InternalLink>         | A restore from an arbitrary point in time within the revision history of a backup.                                                                           | <ul><li>CockroachDB Standard and CockroachDB Basic — self-managed backups</li><li>CockroachDB Advanced — self-managed backups</li><li>CockroachDB with an <InternalLink path="licensing-faqs">Enterprise license</InternalLink></li><ul /></ul>                     |
| <InternalLink path="take-and-restore-encrypted-backups">Encrypted backup and restore</InternalLink>                                   | An encrypted backup using a KMS or passphrase.                                                                                                               | <ul><li>CockroachDB Standard and CockroachDB Basic — self-managed backups</li><li>CockroachDB Advanced — self-managed backups</li><li>CockroachDB with an <InternalLink path="licensing-faqs">Enterprise license</InternalLink></li><ul /></ul>                     |
| <InternalLink path="take-and-restore-locality-aware-backups">Locality-aware backup and restore</InternalLink>                         | A backup where each node writes files to the backup destination that matches the node locality configured at node startup.                                   | <ul><li>CockroachDB Standard and CockroachDB Basic — self-managed backups</li><li>CockroachDB Advanced — self-managed backups</li><li>CockroachDB with an <InternalLink path="licensing-faqs">Enterprise license</InternalLink></li><ul /></ul>                     |
| <InternalLink path="take-locality-restricted-backups">Locality-restricted backup execution</InternalLink>                             | A backup with the `EXECUTION LOCALITY` option restricts the nodes that can execute a backup job with a defined locality filter.                              | <ul><li>CockroachDB Standard and CockroachDB Basic — self-managed backups</li><li>CockroachDB Advanced — self-managed backups</li><li>CockroachDB with an <InternalLink path="licensing-faqs">Enterprise license</InternalLink></li><ul /></ul>                     |

### Additional backup and restore features

* <InternalLink path="take-full-and-incremental-backups#incremental-backups-with-explicitly-specified-destinations">Incremental backups with explicitly specified destinations</InternalLink>
* <InternalLink path="take-full-and-incremental-backups">Exclude a table's data from backups</InternalLink>

## Scheduled backups

<Tip>
  We recommend using scheduled backups to automate daily backups of your cluster.
</Tip>

CockroachDB supports <InternalLink path="create-schedule-for-backup">creating schedules for periodic backups</InternalLink>. Scheduled backups ensure that the data to be backed up is protected from garbage collection until it has been successfully backed up. This active management of <InternalLink path="architecture/storage-layer#protected-timestamps">protected timestamps</InternalLink> means that you can run scheduled backups at a cadence independent from the <InternalLink path="configure-replication-zones">GC TTL</InternalLink> of the data.

For detail on scheduled backup features CockroachDB supports:

* <InternalLink path="manage-a-backup-schedule#set-up-monitoring-for-the-backup-schedule">Set up monitoring for the backup schedule</InternalLink>
* <InternalLink path="manage-a-backup-schedule#view-the-schedule">View</InternalLink>, <InternalLink path="manage-a-backup-schedule">pause</InternalLink>, <InternalLink path="manage-a-backup-schedule">resume</InternalLink>, or <InternalLink path="manage-a-backup-schedule">drop</InternalLink> the schedule

## Backup jobs with locality requirements

CockroachDB supports two backup features that use a node's locality to determine how a backup job runs or where the backup data is stored:

* <InternalLink path="take-locality-restricted-backups">Locality-restricted backup execution</InternalLink>: Specify a set of locality filters for a backup job in order to restrict the nodes that can participate in the backup process to that locality. This ensures that the backup job is executed by nodes that meet certain requirements, such as being located in a specific region or having access to a certain storage bucket.
* <InternalLink path="take-and-restore-locality-aware-backups">Locality-aware backup</InternalLink>: Partition and store backup data in a way that is optimized for locality. When you run a locality-aware backup, nodes write backup data to the <InternalLink path="use-cloud-storage">cloud storage</InternalLink> bucket that is closest to the node locality configured at <InternalLink path="cockroach-start">node startup</InternalLink>.

## Backup and restore SQL statements

The following table outlines SQL statements you can use to create, configure, pause, and show backup and restore jobs:

| SQL Statement                                                                               | Description                                                                                                                                                   |
| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <InternalLink path="backup">`BACKUP`</InternalLink>                                         | Create full and incremental backups.                                                                                                                          |
| <InternalLink path="show-jobs">`SHOW JOBS`</InternalLink>                                   | Show a list of all running jobs or show the details of a specific job by its `job ID`.                                                                        |
| <InternalLink path="pause-job">`PAUSE JOB`</InternalLink>                                   | Pause a backup or restore job with its `job ID`.                                                                                                              |
| <InternalLink path="resume-job">`RESUME JOB`</InternalLink>                                 | Resume a backup or restore job with its `job ID`.                                                                                                             |
| <InternalLink path="cancel-job">`CANCEL JOB`</InternalLink>                                 | Cancel a backup or restore job with its `job ID`.                                                                                                             |
| <InternalLink path="show-backup">`SHOW BACKUP`</InternalLink>                               | Show a backup's details at the <InternalLink path="take-full-and-incremental-backups#backup-collections">backup collection's</InternalLink> storage location. |
| <InternalLink path="restore">`RESTORE`</InternalLink>                                       | Restore full and incremental backups.                                                                                                                         |
| <InternalLink path="alter-backup">`ALTER BACKUP`</InternalLink>                             | Add a new <InternalLink path="take-and-restore-encrypted-backups#use-key-management-service">KMS encryption key</InternalLink> to an encrypted backup.        |
| <InternalLink path="create-schedule-for-backup">`CREATE SCHEDULE FOR BACKUP`</InternalLink> | Create a schedule for periodic backups.                                                                                                                       |
| <InternalLink path="alter-backup-schedule">`ALTER BACKUP SCHEDULE`</InternalLink>           | Alter an existing backup schedule.                                                                                                                            |
| <InternalLink path="show-schedules">`SHOW SCHEDULES`</InternalLink>                         | View information on backup schedules.                                                                                                                         |
| <InternalLink path="pause-schedules">`PAUSE SCHEDULES`</InternalLink>                       | Pause backup schedules.                                                                                                                                       |
| <InternalLink path="resume-schedules">`RESUME SCHEDULES`</InternalLink>                     | Resume paused backup schedules.                                                                                                                               |
| <InternalLink path="drop-schedules">`DROP SCHEDULES`</InternalLink>                         | Drop backup schedules.                                                                                                                                        |

## Backup storage

We recommend taking backups to <InternalLink path="use-cloud-storage">cloud storage</InternalLink> and enabling object locking to protect the validity of your backups. CockroachDB supports Amazon S3, Azure Storage, and Google Cloud Storage for backups. Read the following usage information:

* <InternalLink path="use-cloud-storage#example-file-urls">Example file URLs</InternalLink> to form the URL that you pass to `BACKUP` and `RESTORE` statements.
* <InternalLink path="cloud-storage-authentication">Authentication</InternalLink> to set up authentication to a cloud storage bucket and include those credentials in the URL.

For detail on additional cloud storage features CockroachDB supports:

* Prevent backups from being overwritten or deleted with <InternalLink path="use-cloud-storage#immutable-storage">immutable storage buckets</InternalLink>.
* Set a specific storage class for your backups with <InternalLink path="use-cloud-storage#amazon-s3-storage-classes">Storage Class (AWS S3 only)</InternalLink>.
* <InternalLink path="expire-past-backups">Expire past backups</InternalLink> from cloud storage

<Note>
  Cockroach Labs recommends enabling Egress Perimeter Controls on CockroachDB Advanced clusters to mitigate the risk of data exfiltration when accessing external resources, such as cloud storage for change data capture or backup and restore operations. See <InternalLink version="cockroachcloud" path="egress-perimeter-controls">Egress Perimeter Controls</InternalLink> for detail and setup instructions.
</Note>

## Backup and restore observability

You can verify that your stored backups are restorable with backup validation. While a successful restore completely validates a backup, the validation tools offer a faster alternative and return an error message if a backup is not valid. There are three "levels" of verifying backups that give increasing validation coverage depending on the amount of runtime you want to invest in validating backups.

See the <InternalLink path="backup-validation">Backup Validation</InternalLink> page for detail and examples.

You can track backup jobs using metrics that cover scheduled backups, status of running jobs, and details on completed or failed jobs. You can alert on these metrics via the Prometheus endpoint or the Datadog integration.

See the <InternalLink path="backup-and-restore-monitoring">Backup and Restore Monitoring</InternalLink> page for product availability and a list of the available metrics.

## See also

* Considerations for using <InternalLink path="backup#considerations">backup</InternalLink> and <InternalLink path="restore#considerations">restore</InternalLink>
* <InternalLink path="take-full-and-incremental-backups#backup-collections">Backup collections</InternalLink> for details on how CockroachDB stores backups
* <InternalLink path="restoring-backups-across-versions">Restoring backups</InternalLink> across major versions of CockroachDB
