Created
October 7, 2021 12:57
-
-
Save Slach/11635cdfe54d1a74842bfb7e45d73409 to your computer and use it in GitHub Desktop.
clickhouse-backup selective create_remote \ restore_remote
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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