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

On this page Carat arrow pointing down
Warning:
CockroachDB v21.2 is no longer supported as of May 16, 2023. For more details, refer to the Release Support Policy.

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

Note:

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

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.

Create a backup with revision history

icon/buttons/copy
> BACKUP INTO '{destination}' 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 for Bulk Operations.

Point-in-time restore

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 '(destination)' 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