Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ NAME:
clickhouse-backup tables - List of tables, exclude skip_tables

USAGE:
clickhouse-backup tables [--tables=<db>.<table>] [--remote-backup=<backup-name>] [--all]
clickhouse-backup tables [--tables=<db>.<table>] [--remote-backup=<backup-name>] [--local-backup=<backup-name>] [-f, --format=<text|json|yaml|csv|tsv>] [--all]

OPTIONS:
--config value, -c value Config 'FILE' name. (default: "/etc/clickhouse-backup/config.yml") [$CLICKHOUSE_BACKUP_CONFIG]
--environment-override value, --env value override any environment variable via CLI parameter
--all, -a Print table even when match with skip_tables pattern
--table value, --tables value, -t value List tables only match with table name patterns, separated by comma, allow ? and * as wildcard
--remote-backup value List tables from remote backup
--remote-backup value List tables from a remote backup, including per-table size and parts count
--local-backup value List tables from a local backup (read from disk, no live ClickHouse query), including per-table size and parts count
--format value, -f value Output format (text|json|yaml|csv|tsv)

```
### CLI command - create
Expand Down Expand Up @@ -193,7 +195,7 @@ Look at the system.parts partition and partition_id fields for details https://c
--restore-schema-as-attach Use DETACH/ATTACH instead of DROP/CREATE for schema restoration
--replicated-copy-to-detached Copy data to detached folder for Replicated*MergeTree tables but skip ATTACH PART step
--skip-empty-tables Skip restoring tables that have no data (empty tables with only schema)

```
### CLI command - restore_remote
```
Expand Down Expand Up @@ -231,7 +233,7 @@ Look at the system.parts partition and partition_id fields for details https://c
--restore-schema-as-attach Use DETACH/ATTACH instead of DROP/CREATE for schema restoration
--hardlink-exists-files Create hardlinks for existing files instead of downloading
--skip-empty-tables Skip restoring tables that have no data (empty tables with only schema)

```
### CLI command - delete
```
Expand Down
18 changes: 11 additions & 7 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,17 +429,19 @@ Kill selected command from `GET /backup/actions` command list, kill process shou

### GET /backup/tables

Print list of tables: `curl -s localhost:7171/backup/tables | jq .`, exclude pattern matched tables from `skip_tables` configuration parameters
Print list of tables: `curl -s localhost:7171/backup/tables | jq .`, exclude pattern matched tables from `skip_tables` configuration parameters.

- Optional query argument `table` works the same as the `--table=pattern` CLI argument.
- Optional query argument `remote_backup` or `remote-backup` works the same as `--remote-backup=name` CLI argument.
- Optional query argument `remote_backup` (or `remote-backup`) works the same as the `--remote-backup=name` CLI argument. The response then includes per-table `size`, `total_bytes`, `parts`, and `disks` (JSON array of disk names) fields read from the remote backup metadata.
- Optional query argument `local_backup` (or `local-backup`) works the same as the `--local-backup=name` CLI argument: it lists tables from a local backup directly from disk (no live ClickHouse query required), with `size`, `total_bytes`, `parts`, and `disks` (JSON array) fields.

### GET /backup/tables/all

Print list of tables: `curl -s localhost:7171/backup/tables/all | jq .`, ignore `skip_tables` configuration parameters.

- Optional query argument `table` works the same as the `--table=pattern` CLI argument.
- Optional query argument `remote_backup`or `remote-backup` works the same as `--remote-backup=name` CLI argument.
- Optional query argument `remote_backup` (or `remote-backup`) works the same as the `--remote-backup=name` CLI argument; response shape matches `GET /backup/tables` with the remote-backup parameter.
- Optional query argument `local_backup` (or `local-backup`) works the same as the `--local-backup=name` CLI argument; response shape matches `GET /backup/tables` with the local-backup parameter.

### POST /backup/create

Expand Down Expand Up @@ -666,14 +668,16 @@ NAME:
clickhouse-backup tables - List of tables, exclude skip_tables

USAGE:
clickhouse-backup tables [--tables=<db>.<table>] [--remote-backup=<backup-name>] [--all]
clickhouse-backup tables [--tables=<db>.<table>] [--remote-backup=<backup-name>] [--local-backup=<backup-name>] [-f, --format=<text|json|yaml|csv|tsv>] [--all]

OPTIONS:
--config value, -c value Config 'FILE' name. (default: "/etc/clickhouse-backup/config.yml") [$CLICKHOUSE_BACKUP_CONFIG]
--environment-override value, --env value override any environment variable via CLI parameter
--all, -a Print table even when match with skip_tables pattern
--table value, --tables value, -t value List tables only match with table name patterns, separated by comma, allow ? and * as wildcard
--remote-backup value List tables from remote backup
--remote-backup value List tables from a remote backup, including per-table size and parts count
--local-backup value List tables from a local backup (read from disk, no live ClickHouse query), including per-table size and parts count
--format value, -f value Output format (text|json|yaml|csv|tsv)

```
### CLI command - create
Expand Down Expand Up @@ -855,7 +859,7 @@ Look at the system.parts partition and partition_id fields for details https://c
--restore-schema-as-attach Use DETACH/ATTACH instead of DROP/CREATE for schema restoration
--replicated-copy-to-detached Copy data to detached folder for Replicated*MergeTree tables but skip ATTACH PART step
--skip-empty-tables Skip restoring tables that have no data (empty tables with only schema)

```
### CLI command - restore_remote
```
Expand Down Expand Up @@ -893,7 +897,7 @@ Look at the system.parts partition and partition_id fields for details https://c
--restore-schema-as-attach Use DETACH/ATTACH instead of DROP/CREATE for schema restoration
--hardlink-exists-files Create hardlinks for existing files instead of downloading
--skip-empty-tables Skip restoring tables that have no data (empty tables with only schema)

```
### CLI command - delete
```
Expand Down
16 changes: 13 additions & 3 deletions cmd/clickhouse-backup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ func main() {
{
Name: "tables",
Usage: "List of tables, exclude skip_tables",
UsageText: "clickhouse-backup tables [--tables=<db>.<table>] [--remote-backup=<backup-name>] [--all]",
UsageText: "clickhouse-backup tables [--tables=<db>.<table>] [--remote-backup=<backup-name>] [--local-backup=<backup-name>] [-f, --format=<text|json|yaml|csv|tsv>] [--all]",
Action: func(c *cli.Context) error {
b := backup.NewBackuper(config.GetConfigFromCli(c))
return b.PrintTables(c.Bool("all"), c.String("table"), c.String("remote-backup"))
return b.PrintTables(c.Bool("all"), c.String("table"), c.String("remote-backup"), c.String("local-backup"), c.String("format"))
},
Flags: append(cliapp.Flags,
cli.BoolFlag{
Expand All @@ -106,7 +106,17 @@ func main() {
cli.StringFlag{
Name: "remote-backup",
Hidden: false,
Usage: "List tables from remote backup",
Usage: "List tables from a remote backup, including per-table size and parts count",
},
cli.StringFlag{
Name: "local-backup",
Hidden: false,
Usage: "List tables from a local backup (read from disk, no live ClickHouse query), including per-table size and parts count",
},
cli.StringFlag{
Name: "format, f",
Hidden: false,
Usage: "Output format (text|json|yaml|csv|tsv)",
},
),
},
Expand Down
4 changes: 2 additions & 2 deletions generate_manual.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
CLICKHOUSE_BACKUP_BIN=${CLICKHOUSE_BACKUP_BIN:-build/linux/$(dpkg --print-architecture)/clickhouse-backup}
make clean ${CLICKHOUSE_BACKUP_BIN}
CLICKHOUSE_BACKUP_BIN=${CLICKHOUSE_BACKUP_BIN:-build/$(go env GOOS)/$(go env GOARCH)/clickhouse-backup}
make clean ${CLICKHOUSE_BACKUP_BIN} >&2
cmds=(
tables
create
Expand Down
Loading