2

I have a clickhouse instance running wherein I have installed clickhouse-backup. I've connected to it and have no issues running clickhouse-client with a custom user like this:

clickhouse-client -u fred --password 12345

but when I do a clickhouse-backup tables I get

can't connect to clickhouse: code: 516, message: default: Authentication failed: password is incorrect or there is no user with such name. 

How do I run the command clickhouse-backup tables as my custom user 'fred'?

vitaliis
  • 4,082
  • 5
  • 18
  • 40

1 Answers1

4

It needs to define these credentials in config.yml file:

..
clickhouse:
  username: fred              # CLICKHOUSE_USERNAME
  password: 12345             # CLICKHOUSE_PASSWORD
..

By default config file is located /etc/clickhouse-backup/config.yml.

To define custom location pass it in --config param.


As the alternate way, the required params can be passed through environmental variables. Consider run clickhouse-backup as docker-container:

# generate a backup plan

sudo docker run --rm -it --network host -v "/var/lib/clickhouse:/var/lib/clickhouse" \
    -e CLICKHOUSE_FREEZE_BY_PART=true \
    -e CLICKHOUSE_USERNAME=user \
    -e CLICKHOUSE_PASSWORD=passw \
    \
    alexakulov/clickhouse-backup:latest create --tables="db.table1_local" "table1 [shard-01]"


# start a backup process

sudo docker run --rm -it --network host -v "/var/lib/clickhouse:/var/lib/clickhouse" \
    -e CLICKHOUSE_USERNAME=user \
    -e CLICKHOUSE_PASSWORD=passw \
    -e REMOTE_STORAGE=gcs \
    -e GCS_BUCKET=gcs-clickhouse-backup-bucket \
    -e GCS_CREDENTIALS_JSON='_credentials_json_' \
    \
    alexakulov/clickhouse-backup:latest upload "table1 [shard-01]"


# remove the local copy of backup

sudo docker run --rm -it --network host -v "/var/lib/clickhouse:/var/lib/clickhouse" \
    \
    alexakulov/clickhouse-backup:latest delete local "table1 [shard-01]"

vladimir
  • 13,428
  • 2
  • 44
  • 70
  • Nice! How do I pass the password in this command `clickhouse-backup tables --config config.yml` I have tried using `--password 12345` but that doesn't work. –  Jan 26 '21 at 06:36
  • 1
    @77Rodged it needs to pass password inside *config.yml*. See format this file here - https://github.com/AlexAkulov/clickhouse-backup#default-config – vladimir Jan 26 '21 at 06:52