Take Backups with Revision History and Restore from a Point-in-time

On this page Carat arrow pointing down
Note:

BACKUP with revision history is an Enterprise-only feature. However, you can take full backups without an Enterprise license.

This page provides information about how to take backups with revision history and restore from a point-in-time.

You can create full or incremental backups with revision history:

  • Taking full backups with revision history allows you to back up every change made within the garbage collection period leading up to and including the given timestamp.
  • Taking incremental backups with revision history allows you to back up every change made since the last backup and within the garbage collection period leading up to and including the given timestamp. You can take incremental backups with revision history even when your previous full or incremental backups were taken without revision history.

You can configure garbage collection periods using the ttlseconds replication zone setting. Taking backups with revision history allows for point-in-time restores within the revision history.

Note:

If you are creating incremental backups as part of a backup schedule, protected timestamps will ensure the backup revision data is not garbage collected, which allows you to lower the GC TTL. See Protected timestamps and scheduled backups for more detail.

Supported products

The feature described on this page is available in CockroachDB Basic, CockroachDB Standard, CockroachDB Advanced, and CockroachDB Self-Hosted clusters when you are running self-managed backups. For a full list of features, refer to Backup and restore product support.

Create a backup with revision history

icon/buttons/copy
> BACKUP INTO '{collectionURI}' AS OF SYSTEM TIME '-10s' WITH revision_history;

For guidance on connecting to Amazon S3, Google Cloud Storage, Azure Storage, and other storage options, read Use Cloud Storage.

Point-in-time restore

Warning:

RESTORE will only restore the latest data in an object (table, database, cluster), or the latest data as per an AS OF SYSTEM TIME restore. A restore will not include historical data even if you ran your backup with revision_history. This means that if you issue an AS OF SYSTEM TIME query on a restored object, the query will fail or the response will be incorrect because there is no historical data to query.

If the full or incremental backup was taken with revision history, you can restore the data as it existed at an arbitrary point-in-time within the revision history captured by that backup. Use the AS OF SYSTEM TIME clause to specify the point-in-time.

Additionally, if you want to restore a specific incremental backup, you can do so by specifying the end_time of the backup by using the AS OF SYSTEM TIME clause. To find the incremental backup's end_time, use SHOW BACKUP.

If you do not specify a point-in-time, the data will be restored to the backup timestamp; that is, the restore will work as if the data was backed up without revision history.

icon/buttons/copy
> RESTORE FROM '/2021/12/13-211056.62' IN '{collectionURI}' AS OF SYSTEM TIME '2021-12-13 10:00:00';

To view the available backup subdirectories you can restore from, use SHOW BACKUPS.

See also


Yes No
On this page

Yes No