Clickhouse Backups

How to install clickhouse Database in Centos 7


Install clickhouse backup
wget https://github.com/AlexAkulov/clickhouse-backup/releases/download/v0.5.2/clickhouse-backup.tar.gz
tar -zxvf clickhouse-backup.tar.gz
cd /root/clickhouse-backup

nano config.yml

edit clickhouse password , clickhouse port, clickhouse data path

Sample Config file :


general:
remote_storage: s3
disable_progress_bar: false
backups_to_keep_local: 0
backups_to_keep_remote: 0
clickhouse:
username: default
password: "ENTER_CLICKHOUSE_PASSWORD"
host: localhost
port: ENTER_CLICKHOUSE_PORT
data_path: "ENTER_CLICKHOUSE_DATA_PATH"
skip_tables:
- system.*
timeout: 5m
freeze_by_part: false
s3:
access_key: ""
secret_key: ""
bucket: ""
endpoint: ""
region: us-east-1
acl: private
force_path_style: false
path: ""
disable_ssl: false
part_size: 104857600
compression_level: 1
compression_format: gzip
sse: ""
disable_cert_verification: false
gcs:
credentials_file: ""
credentials_json: ""
bucket: ""
path: ""
compression_level: 1
compression_format: gzip
cos:
url: ""
timeout: 2m
secret_id: ""
secret_key: ""
path: ""
compression_format: gzip
compression_level: 1
debug: false


------------

nano /root/clickhouse-backup/config.yml

------------------

Make Bash file for cron job
nano chousebackup.sh


#!/bin/bash
BACKUP_NAME=my_backup_$(date -u +%Y-%m-%dT%H-%M-%S)
/root/clickhouse-backup/clickhouse-backup create --config "/root/clickhouse-backup/config.yml" $BACKUP_NAME


chmod 0755 chousebackup.sh

./chousebackup.sh

----------------------
cronjob setup
crontab -e
0 1 * * * /root/clickhouse-backup/chousebackup.sh 2>&1


--------------------------

Backups are created at location : /var/lib/clickhouse/backup/

cd /var/lib/clickhouse/backup/

ls

Check size of backups :

du -sh

du -sh *

---------------------

---------------------
Some commands
/root/clickhouse-backup/clickhouse-backup help
/root/clickhouse-backup/clickhouse-backup list --config "/root/clickhouse-backup/config.yml"
/root/clickhouse-backup/clickhouse-backup clean --config "/root/clickhouse-backup/config.yml"
------------
Delete old backups
/root/clickhouse-backup/clickhouse-backup delete local my_backup_2020-10-14T09-53-17 --config "/root/clickhouse-backup/config.yml"
------------------
move paricular back to anohter server and import there
rsync -avzP --progress /var/lib/clickhouse/backup/my_backup_2020-10-14T09-55-19 [email protected]:/var/lib/clickhouse/backup/


after moving import particluar table data
clickhouse-client -m --port=8000 --user=default --password=MYPASSWORD


restore whole database
/root/clickhouse-backup/clickhouse-backup restore --config "/root/clickhouse-backup/config.yml" my_backup_2020-10-14T09-55-19
/root/clickhouse-backup/clickhouse-backup restore --config "/root/clickhouse-backup/config.yml" 02-08-2020 -t default.apilogs;




Dated : 2020-10-14 15:11:52

Category : Server handling

Tags : Clickhouse

Leave Your Comment

Related Posts