backup_log 시스템 테이블
backup_log 시스템 테이블
backup_log 시스템 테이블은 BACKUP와 RESTORE 작업에 대한 정보가 담긴 로깅 항목들을 담고 있어요.
출처: 문서
본문
Querying in ClickHouse Cloud 이 시스템 테이블의 데이터는 ClickHouse Cloud의 각 노드에 로컬로 보관돼요. 따라서 모든 데이터에 대한 완전한 뷰를 얻으려면 clusterAllReplicas 함수가 필요해요. 자세한 내용은 여기를 참고해요.
Description (설명)
BACKUP와 RESTORE 작업에 대한 정보가 담긴 로깅 항목들을 담고 있어요. 언제든지 이 테이블을 잘라내거나 드롭해도 안전해요.
Columns (열)
hostname(LowCardinality(String)) — 쿼리를 실행한 서버의 호스트 이름.clickhouse_version(LowCardinality(String)) — 행을 생성한 ClickHouse 서버의 버전.system_processor(LowCardinality(String)) — 행을 생성한 ClickHouse 서버의 CPU 아키텍처.event_date(Date) — 항목의 날짜.event_time(DateTime) — 항목의 시간.event_time_microseconds(DateTime64(6)) — 항목의 시간(마이크로초 정밀도).id(String) — 백업 또는 복원 작업의 식별자.name(String) — 백업 스토리지의 이름(FROM 또는 TO 절의 내용).base_backup_name(String) — 증분 백업인 경우 기본 백업의 이름.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)) — 백업 엔진의 리더/라이터가 효과적으로 사용한 설정(예: S3allow_native_copy). 평면 맵으로 표현할 수 없어 하나 이상의 엔진이 관련된 작업(증분 백업 및 복원, 경량 스냅샷 복원, 비내부ON CLUSTER작업)에서는 비어 있음.
Example (예제)
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 │
└──────────────────────────────────────┴───────────────────────────────┴────────────────┴───────┴─────────────────────┴─────────────────────┴───────────┴────────────┴─────────────┴───────────────────┴─────────────────┴────────────┴────────────┘