Skip to content

Commit

Permalink
Backup Kapacitor database
Browse files Browse the repository at this point in the history
  • Loading branch information
afausti committed Jan 4, 2025
1 parent 2e5404f commit 0c73052
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions backup/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ for item in $BACKUP_ITEMS; do
;;
"chronograf")
if [ "$enabled" == "true" ]; then
echo "Backing up Chronograf..."
echo "\nBacking up Chronograf..."
pod=$(kubectl get pods -n sasquatch -l app=sasquatch-chronograf -o jsonpath='{.items[0].metadata.name}')
backup_dir="/backup/chronograf-$(date +%Y-%m-%d)"
mkdir -p "$backup_dir"
Expand All @@ -49,7 +49,17 @@ for item in $BACKUP_ITEMS; do
;;
"kapacitor")
if [ "$enabled" == "true" ]; then
echo "Backing up Kapacitor..."
echo "\nBacking up Kapacitor..."
pod=$(kubectl get pods -n sasquatch -l app=sasquatch-kapacitor -o jsonpath='{.items[0].metadata.name}')
backup_dir="/backup/kapacitor-$(date +%Y-%m-%d)"
mkdir -p "$backup_dir"
kubectl cp -n sasquatch $pod:/var/lib/kapacitor/kapacitor.db "$backup_dir"/kapacitor.db
if [ $? -eq 0 ] && [ -f "$backup_dir/kapacitor.db" ]; then
echo "Backup completed successfully at $backup_dir."
else
echo "Backup failed!" >&2
exit 1
fi
else
echo "Skipping Kapacitor..."
fi
Expand Down

0 comments on commit 0c73052

Please sign in to comment.