Skip to content

Latest commit

 

History

History
100 lines (69 loc) · 2.94 KB

sql-statement-show-backups.md

File metadata and controls

100 lines (69 loc) · 2.94 KB
title summary aliases
SHOW [BACKUPS|RESTORES] | TiDB SQL Statement Reference
An overview of the usage of SHOW [BACKUPS|RESTORES] for the TiDB database.
/docs/dev/sql-statements/sql-statement-show-backups/

SHOW [BACKUPS|RESTORES]

This statement shows a list of all queued and running BACKUP and RESTORE tasks.

Use SHOW BACKUPS to query BACKUP tasks and use SHOW RESTORES to query RESTORE tasks. Both statements require SUPER privilege to run.

Synopsis

ShowBRIEStmt ::=
    "SHOW" ("BACKUPS" | "RESTORES") ShowLikeOrWhere?

ShowLikeOrWhere ::=
    "LIKE" SimpleExpr
|   "WHERE" Expression

Examples

In one connection, execute the following statement:

{{< copyable "sql" >}}

BACKUP DATABASE `test` TO 's3://example-bucket/backup-01/?region=us-west-1';

Before the backup completes, run SHOW BACKUPS in a new connection:

{{< copyable "sql" >}}

SHOW BACKUPS;
+--------------------------------+---------+----------+---------------------+---------------------+-------------+------------+
| Destination                    | State   | Progress | Queue_Time          | Execution_Time      | Finish_Time | Connection |
+--------------------------------+---------+----------+---------------------+---------------------+-------------+------------+
| s3://example-bucket/backup-01/ | Backup  | 98.38    | 2020-04-12 23:09:03 | 2020-04-12 23:09:25 |        NULL |          4 |
+--------------------------------+---------+----------+---------------------+---------------------+-------------+------------+
1 row in set (0.00 sec)

The first row of the result above is described as follows:

Column Description
Destination The destination URL (with all parameters stripped to avoid leaking secret keys)
State State of the task
Progress Estimated progress in the current state as a percentage
Queue_Time When the task was queued
Execution_Time When the task was started; the value is 0000-00-00 00:00:00 for queueing tasks
Finish_Time (not used for now)
Connection Connection ID running this task

The connection ID can be used to cancel a backup/restore task via the KILL TIDB QUERY statement.

{{< copyable "sql" >}}

KILL TIDB QUERY 4;
Query OK, 0 rows affected (0.00 sec)

Filtering

Use the LIKE clause to filter out tasks by matching the destination URL against a wildcard expression.

{{< copyable "sql" >}}

SHOW BACKUPS LIKE 's3://%';

Use the WHERE clause to filter by columns.

{{< copyable "sql" >}}

SHOW BACKUPS WHERE `Progress` < 25.0;

MySQL compatibility

This statement is a TiDB extension to MySQL syntax.

See also