SHOW BACKUP lists the contents of a backup created with the statement.
On self-hosted clusters, a feature is available in that improves backup query performance and simplifies backup operations. Refer to Query backups more efficiently.
Required privileges
SHOW BACKUP requires read permissions to its target destination.
You can grant a user the EXTERNALIOIMPLICITACCESS to interact with external resources that require implicit access.
Either the EXTERNALIOIMPLICITACCESS or the role is required for the following scenarios:
- Interacting with a cloud storage resource using .
- Using a custom endpoint on S3.
- Using the command.
- Interacting with an Amazon S3 and Google Cloud Storage resource using
SPECIFIEDcredentials. Azure Storage is alwaysSPECIFIEDby default. - Using storage.
Synopsis
Parameters
Options
Response
The following fields are returned:
See Show a backup with descriptor IDs for the responses displayed when the
WITH debug_ids option is specified.
Query backups more efficiently
This feature is available in for self-hosted clusters.
- Significantly faster performance for listing backups in a collection
- Server-side time filtering, using
NEWER THANandOLDER THANclauses - Unique backup IDs that simplify
- No
AS OF SYSTEM TIMErequired when restoring from a backup ID
Backups taken when the cluster was on versions prior to v26.1 will not appear when using
use_backups_with_ids=true. The backup ID interface requires backup index files that were introduced in v26.1. After your pre-v26.1 backups have expired, per your retention policy, this limitation will no longer affect your use of this feature.Enable the backup ID interface
To use the backup ID interface, set the session variable:List backups with time filtering
Whenuse_backups_with_ids is enabled, SHOW BACKUPS IN returns the backup ID, backup time, and revision start time for each backup:
id: A unique identifier for the backupbackup_time: The end time of the backup (equivalent to the time you can restore to)
Time filtering
UseNEWER THAN and OLDER THAN to filter backups by age:
Show a specific backup by ID
To view the contents of a specific backup, use its backup ID (from theid column in the SHOW BACKUPS IN output):
SHOW BACKUP output, including all databases, tables, and metadata for that specific backup.
Show revision history backup windows
For backups taken with , use theWITH REVISION START TIME option to display the revision history window for each backup:
revision_start_time column shows the earliest timestamp you can restore to for each backup. This represents the start of the revision history window. For backups without revision history, this column displays NULL.
Without the WITH REVISION START TIME option, the revision_start_time column does not appear in the output, and only the id and backup_time columns are shown.
For details on performing point-in-time restores using revision history backups, see .
Examples
The examples in this section use one of the following storage URIs:- External connections, which allow you to represent an external storage or sink URI. You can then specify the external connection’s name in statements rather than the provider-specific URI. For detail on using external connections, see the page.
- Amazon S3 connection strings with the default
AUTH=specifiedparameter. For guidance on usingAUTH=implicitauthentication with Amazon S3 buckets instead, read .
View a list of the available full backup subdirectories
To view a list of the available subdirectories, use the following command:<year/<month/<day-<timestamp.
Show the most recent backup
To view the most recent backup, use theLATEST syntax:
View a list of the full and incremental backups in a specific full backup subdirectory
To view a list of the and backups in a specific subdirectory, use the following command:Show locality-aware backups
To view a list of , pass the endpoint that is set as thedefault location with COCKROACH_LOCALITY=default:
SHOW BACKUP:
Show a backup with schemas
Show a backup with privileges
Use theWITH privileges option to view a list of which users and roles had which privileges on each database and table in the backup. This parameter also displays the original owner of objects in the backup:
SHOW BACKUP. It is necessary to run SHOW BACKUP with the specific backup directory rather than the backup collection’s top-level directory. Use SHOW BACKUPS IN with your storage location to list the backup directories it contains, which can then be run with SHOW BACKUP to inspect the metadata.
Show details for scheduled backups
When a , it is stored within a collection of backups in the given collection URI. To view details for a backup created by a schedule, you can use the following:SHOW BACKUPS IN collectionURIstatement to view a list of the available full backup subdirectories.SHOW BACKUP FROM subdirectory IN collectionURIstatement to view a list of the full and incremental backups that are stored in a specific full backup’s subdirectory.
Show an encrypted backup
Depending on how the backup was , use the and the same passphrase that was used to create the backup:kms option and the same KMS URI that was used to create the backup:
Show a backup with descriptor IDs
UseWITH debug_ids to display the descriptor IDs related to each object in the backup:
Validate a backup’s files
-
Use
SHOW BACKUP ... check_fileswith a backup for validation:This will return the following output after validating that the backup files are correct and present:The output will returnfile_bytesalong with the columns you receive fromSHOW BACKUPwithoutcheck_files. Thefile_bytescolumn indicates the estimated bytes in external storage for a particular table object. For more detail on the output columns, see theSHOW BACKUPtable. -
If
SHOW BACKUP ... check_filescannot read from a file, it will return an error message similar to the following:SHOW BACKUP ... check_fileswill return up to ten file paths for incorrect or missing files.
Show a backup’s internal metadata
Use theWITH as_json option to output a backup’s internal metadata, contained in its manifest file, as a JSON value:
manifest column with the file’s contents as the JSON value. Use to query particular data or edit the format of the response.
The response returned from
SHOW BACKUP FROM ... WITH as_json is a backup’s internal metadata. This content is subject to change from version to version of CockroachDB and does not offer the same stability guarantees as the other SHOW BACKUP options and their responses. As a result, as_json should only be used for debugging or general inspection purposes.
