File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
addons/kafka/dataprotection Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 11#! /bin/bash
22
3+ # if the script exits with a non-zero exit code, touch a file to indicate that the backup failed,
4+ # the sync progress container will check this file and exit if it exists
5+ function handle_exit() {
6+ exit_code=$?
7+ if [ $exit_code -ne 0 ]; then
8+ echo " failed with exit code $exit_code "
9+ touch " ${DP_BACKUP_INFO_FILE} .exit"
10+ exit $exit_code
11+ fi
12+ }
13+
14+ trap handle_exit EXIT
15+
316# topics.txt format is like:
417# (topic name) (partitions) (replication factor)
518# topic1 1 1
619# topic2 1 1
720#
821# We also ignores the __consumer_offsets topic as offsets won't be backuped up.
922echo " getting topics..."
10- kafkactl get topics | tail -n +2 | grep -v __consumer_offsets | datasafed push - topics.txt
23+ topic_list=$( kafkactl get topics | tail -n +2)
24+ if [[ -z $topic_list ]]; then
25+ echo " nothing to backup"
26+ exit 1
27+ fi
28+ echo $topic_list | grep -v __consumer_offsets | datasafed push - topics.txt
1129readarray -t topics < <( kafkactl get topics -o compact | grep -v __consumer_offsets)
1230
1331for topic in " ${topics[@]} " ; do
Original file line number Diff line number Diff line change @@ -26,3 +26,15 @@ function DP_save_backup_status_info() {
2626export BROKERS=" $DP_DB_HOST :$DP_DB_PORT "
2727export PATH=" $PATH :$DP_DATASAFED_BIN_PATH "
2828export DATASAFED_BACKEND_BASE_PATH=${DP_BACKUP_BASE_PATH}
29+
30+ if [[ $KB_KAFKA_SASL_ENABLE == " true" ]]; then
31+ echo " using sasl auth.."
32+ if [[ $KB_KAFKA_SASL_MECHANISMS != * " PLAIN" * ]]; then
33+ echo " unsupported KB_KAFKA_SASL_MECHANISMS: $KB_KAFKA_SASL_MECHANISMS "
34+ exit 1
35+ fi
36+ export SASL_ENABLED=" true"
37+ export SASL_MECHANISM=" plaintext"
38+ export SASL_USERNAME=$KAFKA_ADMIN_USER
39+ export SASL_PASSWORD=$KAFKA_ADMIN_PASSWORD
40+ fi
You can’t perform that action at this time.
0 commit comments