Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

system.backup_log

描述

包含有关 BACKUPRESTORE 操作的日志记录条目。

  • hostname (LowCardinality(String)) — 执行查询的服务器主机名。
  • event_date (Date) — 条目的日期。
  • event_time (DateTime) — 条目的时间。
  • event_time_microseconds (DateTime64(6)) — 精确到微秒的条目时间。
  • id (String) — 备份或恢复操作的标识符。
  • name (String) — 备份存储的名称 (即 FROMTO 子句的内容) 。
  • base_backup_name (String) — 增量备份场景下的 base backup 名称。
  • query_id (String) — 与备份操作关联的查询 ID。
  • status (Enum8('CREATING_BACKUP' = 0, 'BACKUP_CREATED' = 1, 'BACKUP_FAILED' = 2, 'RESTORING' = 3, 'RESTORED' = 4, 'RESTORE_FAILED' = 5, 'BACKUP_CANCELLED' = 6, 'RESTORE_CANCELLED' = 7)) — 操作状态。
  • error (String) — 操作失败时的错误消息 (成功操作时为空字符串) 。
  • start_time (DateTime64(6)) — 操作的开始时间。
  • end_time (DateTime64(6)) — 操作的结束时间。
  • num_files (UInt64) — 备份中存储的文件数量。
  • total_size (UInt64) — 备份中存储文件的总大小。
  • num_entries (UInt64) — 备份中的条目数,即:如果备份以文件夹形式存储,则表示该文件夹中的文件数;如果备份以归档文件形式存储,则表示该归档文件中的文件数。如果是增量备份,或者其中包含空文件或重复文件,则它与 num_files 不同。以下关系始终成立:num_entries ≤ num_files
  • uncompressed_size (UInt64) — 备份的未压缩大小。
  • compressed_size (UInt64) — 备份的压缩后大小。如果备份不是以归档文件形式存储,则它等于 uncompressed_size
  • files_read (UInt64) — 恢复操作期间读取的文件数。
  • bytes_read (UInt64) — 恢复操作期间读取文件的总大小。
  • settings (Map(LowCardinality(String), String)) — 此操作实际生效的备份/恢复专用设置 (来自 SETTINGS 子句,包括默认值) 。敏感设置不会公开。
  • engine_settings (Map(LowCardinality(String), String)) — 备份引擎读写器实际使用的设置 (例如 S3 allow_native_copy) 。当操作涉及多个无法用扁平 map 表示的引擎时,该字段为空:增量备份和恢复、轻量级快照恢复,以及非内部 ON CLUSTER 操作。

示例

BACKUP TABLE test_db.my_table TO Disk('backups_disk', '1.zip')
┌─id───────────────────────────────────┬─status─────────┐
│ e5b74ecb-f6f1-426a-80be-872f90043885 │ BACKUP_CREATED │
└──────────────────────────────────────┴────────────────┘
SELECT hostname, event_date, event_time_microseconds, id, name, status, error, start_time, end_time, num_files, total_size, num_entries, uncompressed_size, compressed_size, files_read, bytes_read FROM system.backup_log WHERE id = 'e5b74ecb-f6f1-426a-80be-872f90043885' ORDER BY event_date, event_time_microseconds \G
Row 1:
──────
hostname:                clickhouse.eu-central1.internal
event_date:              2023-08-19
event_time_microseconds: 2023-08-19 11:05:21.998566
id:                      e5b74ecb-f6f1-426a-80be-872f90043885
name:                    Disk('backups_disk', '1.zip')
status:                  CREATING_BACKUP
error:                   
start_time:              2023-08-19 11:05:21
end_time:                1970-01-01 03:00:00
num_files:               0
total_size:              0
num_entries:             0
uncompressed_size:       0
compressed_size:         0
files_read:              0
bytes_read:              0

Row 2:
──────
hostname:                clickhouse.eu-central1.internal
event_date:              2023-08-19
event_time:              2023-08-19 11:08:56
event_time_microseconds: 2023-08-19 11:08:56.916192
id:                      e5b74ecb-f6f1-426a-80be-872f90043885
name:                    Disk('backups_disk', '1.zip')
status:                  BACKUP_CREATED
error:                   
start_time:              2023-08-19 11:05:21
end_time:                2023-08-19 11:08:56
num_files:               57
total_size:              4290364870
num_entries:             46
uncompressed_size:       4290362365
compressed_size:         3525068304
files_read:              0
bytes_read:              0
RESTORE TABLE test_db.my_table FROM Disk('backups_disk', '1.zip')
┌─id───────────────────────────────────┬─status───┐
│ cdf1f731-52ef-42da-bc65-2e1bfcd4ce90 │ RESTORED │
└──────────────────────────────────────┴──────────┘
SELECT hostname, event_date, event_time_microseconds, id, name, status, error, start_time, end_time, num_files, total_size, num_entries, uncompressed_size, compressed_size, files_read, bytes_read FROM system.backup_log WHERE id = 'cdf1f731-52ef-42da-bc65-2e1bfcd4ce90' ORDER BY event_date, event_time_microseconds \G
Row 1:
──────
hostname:                clickhouse.eu-central1.internal
event_date:              2023-08-19
event_time_microseconds: 2023-08-19 11:09:19.718077
id:                      cdf1f731-52ef-42da-bc65-2e1bfcd4ce90
name:                    Disk('backups_disk', '1.zip')
status:                  RESTORING
error:                   
start_time:              2023-08-19 11:09:19
end_time:                1970-01-01 03:00:00
num_files:               0
total_size:              0
num_entries:             0
uncompressed_size:       0
compressed_size:         0
files_read:              0
bytes_read:              0

Row 2:
──────
hostname:                clickhouse.eu-central1.internal
event_date:              2023-08-19
event_time_microseconds: 2023-08-19 11:09:29.334234
id:                      cdf1f731-52ef-42da-bc65-2e1bfcd4ce90
name:                    Disk('backups_disk', '1.zip')
status:                  RESTORED
error:                   
start_time:              2023-08-19 11:09:19
end_time:                2023-08-19 11:09:29
num_files:               57
total_size:              4290364870
num_entries:             46
uncompressed_size:       4290362365
compressed_size:         4290362365
files_read:              57
bytes_read:              4290364870

这与系统表 system.backups 中记录的信息基本相同:

SELECT id, name, status, error, start_time, end_time, num_files, total_size, num_entries, uncompressed_size, compressed_size, files_read, bytes_read FROM system.backups ORDER BY start_time
┌─id───────────────────────────────────┬─name──────────────────────────┬─status─────────┬─error─┬──────────start_time─┬────────────end_time─┬─num_files─┬─total_size─┬─num_entries─┬─uncompressed_size─┬─compressed_size─┬─files_read─┬─bytes_read─┐
│ e5b74ecb-f6f1-426a-80be-872f90043885 │ Disk('backups_disk', '1.zip') │ BACKUP_CREATED │       │ 2023-08-19 11:05:21 │ 2023-08-19 11:08:56 │        57 │ 4290364870 │          46 │        4290362365 │      3525068304 │          0 │          0 │
│ cdf1f731-52ef-42da-bc65-2e1bfcd4ce90 │ Disk('backups_disk', '1.zip') │ RESTORED       │       │ 2023-08-19 11:09:19 │ 2023-08-19 11:09:29 │        57 │ 4290364870 │          46 │        4290362365 │      4290362365 │         57 │ 4290364870 │
└──────────────────────────────────────┴───────────────────────────────┴────────────────┴───────┴─────────────────────┴─────────────────────┴───────────┴────────────┴─────────────┴───────────────────┴─────────────────┴────────────┴────────────┘

另请参见

Navigation