Skip to content

Instantly share code, notes, and snippets.

@Slach
Created October 7, 2021 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Slach/11635cdfe54d1a74842bfb7e45d73409 to your computer and use it in GitHub Desktop.
Save Slach/11635cdfe54d1a74842bfb7e45d73409 to your computer and use it in GitHub Desktop.
clickhouse-backup selective create_remote \ restore_remote
#!/bin/bash
backup_date=$(date +%Y-%m-%d-%H-%M-%S)
table_patterns=$1 # for example table_patterns="ns_v2.t_agg_page_h0?_local"
backup_name="full-$backup_date"
backup_command="create_remote --tables=$table_patterns $backup_name"
echo "RUN ${backup_command}"
echo "{\"command\":\"${backup_command}\"}" | curl -XPOST "http://localhost:7171/backup/actions" --data-binary=@-
while [[ "0" == $(curl -s "http://localhost:7171/backup/status" | grep -F "${backup_command}" | grep -c "success|error") ]]; do
printf "."
sleep 0.5
done
echo "RESULT"
curl -s "http://localhost:7171/backup/actions" | grep -F "${backup_command}"
#!/bin/bash
backup_name=$1
table_patterns=$2
1backup_command="restore_remote --rm --tables=$table_patterns $backup_name"
echo "RUN ${backup_command}"
echo "{\"command\":\"${backup_command}\"}" | curl -XPOST "http://localhost:7171/backup/actions" --data-binary=@-
while [[ "0" == $(curl -s "http://localhost:7171/backup/status" | grep -F "${backup_command}" | grep -c "success|error") ]]; do
printf "."
sleep 0.5
done
echo "RESULT"
curl -s "http://localhost:7171/backup/actions" | grep -F "${backup_command}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment