Backup. From Solo

Right now there are several methods to backup clickhouse.

The most tested is Altinity clickhouse-backup. It is not official project, but most tested and has most functionality on the time of writing.

Other runtime options are native CH Backup command (backups only data, no RBAC and configs) and rsync copy with manual ALTER FREEZE.

For easy incremental backups with clickhouse-backup you'll need external S3 storage. Incremental backups created using name comparison of parts folders.

If you want to use local storage with incremental backups you'll have to use additional tools like restic, kopia and pair them with clickhouse-backup.

Firsts, download and install fresh binary.

#Download
wget https://github.com/Altinity/clickhouse-backup/releases/download/v2.4.32/clickhouse-backup-linux-amd64.tar.gz

#Install
tar -xf clickhouse-backup-linux-amd64.tar.gz
sudo install -o root -g root -m 0755 build/linux/amd64/clickhouse-backup /usr/local/bin

#Check
/usr/local/bin/clickhouse-backup -v

Now generate and edit config

#Make directory
mkdir /etc/clickhouse-backup
chown root:clickhouse /etc/clickhouse-backup

#Generate Config
clickhouse-backup default-config > /etc/clickhouse-backup/config.yml

#Check
vi /etc/clickhouse-backup/config.yml

Now you should change 3 sections in config with your data, assuming you CH is default solo paths and user.

Now you can check if backup is working

You can see that backup was created. Notice that shadow directory (used as intermediary) is auto cleaned after backup.

No let's create remote backup

Broken backup can occur due link failure, or while backing up default empty RBAC config without policies, etc. It looks like this

By default create_remote will create 2 backup. Local and remote backups

You can delete either or set limits in clickhouse config. 0 is unlim

Now let's create cron jobs for full backups and incremental. One set each week of the month.

Full backup script for week 1. Make same for 2-4.

And incremental

Now create crontab like this

Change week number in script accordingly

Last updated

Was this helpful?