backup_log
包含有关BACKUP
和RESTORE
操作的信息的日志条目。
列
hostname
(LowCardinality(String)) — 执行查询的服务器的主机名。event_date
(Date) — 条目的日期。event_time
(DateTime) — 条目的日期和时间。event_time_microseconds
(DateTime64) — 带有微秒精度的条目时间。id
(String) — 备份或还原操作的标识符。name
(String) — 备份存储的名称(FROM
或TO
子句的内容)。status
(Enum8) — 操作状态。可能的值'CREATING_BACKUP'
'BACKUP_CREATED'
'BACKUP_FAILED'
'RESTORING'
'RESTORED'
'RESTORE_FAILED'
error
(String) — 失败操作的错误消息(成功操作的空字符串)。start_time
(DateTime) — 操作开始时间。end_time
(DateTime) — 操作结束时间。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) — 还原操作期间读取的文件的总大小。
示例
BACKUP TABLE test_db.my_table TO Disk('backups_disk', '1.zip')
┌─id───────────────────────────────────┬─status─────────┐
│ e5b74ecb-f6f1-426a-80be-872f90043885 │ BACKUP_CREATED │
└──────────────────────────────────────┴────────────────┘
SELECT * 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 * 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 * 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 │
└──────────────────────────────────────┴───────────────────────────────┴────────────────┴───────┴─────────────────────┴─────────────────────┴───────────┴────────────┴─────────────┴───────────────────┴─────────────────┴────────────┴────────────┘
另请参见