Skip to content

Commit

Permalink
Restructure backup script
Browse files Browse the repository at this point in the history
- Backup Cronograf BoltDB
  • Loading branch information
afausti committed Jan 4, 2025
1 parent fd99374 commit 3b89ca7
Showing 1 changed file with 55 additions and 20 deletions.
75 changes: 55 additions & 20 deletions backup/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,60 @@

set -e

# Configuration
BACKUP_DIR="/backup/sasquatch-influxdb-enterprise-backup"
GCS_BUCKET="gs://your-gcs-bucket"

# Ensure the backup directory exists
mkdir -p "$BACKUP_DIR"

echo "Starting InfluxDB Enterprise backup..."

influxd-ctl -bind sasquatch-influxdb-enterprise-meta.sasquatch:8091 backup -strategy incremental "$BACKUP_DIR"

if [ $? -eq 0 ]; then
echo "Backup completed successfully at $BACKUP_DIR."
else
echo "Backup failed!" >&2
exit 1
if [ -z "$BACKUP_ITEMS" ]; then
echo "No backup items specified. Exiting."
exit 0
fi

echo "Starting Chronograf backup..."

kubectl get pods -n sasquatch

BACKUP_ITEMS=$(echo "$BACKUP_ITEMS" | jq -c '.[]')

for item in $BACKUP_ITEMS; do
name=$(echo "$item" | jq -r '.name')
enabled=$(echo "$item" | jq -r '.enabled')

case "$name" in
"influxdb-enterprise")
if [ "$enabled" == "true" ]; then
echo "Backing up InfluxDB Enterprise (incremental backup)..."
backup_dir="/backup/sasquatch-influxdb-enterprise-backup"
mkdir -p "$backup_dir"
influxd-ctl -bind sasquatch-influxdb-enterprise-meta.sasquatch:8091 backup -strategy incremental "$backup_dir"
if [ $? -eq 0 ]; then
echo "Backup completed successfully at $backup_dir."
else
echo "Backup failed!" >&2
exit 1
fi
else
echo "Skipping InfluxDB Enterprise..."
fi
;;
"chronograf")
if [ "$enabled" == "true" ]; then
echo "Backing 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"
kubectl cp -n sasquatch $pod:/var/lib/chronograf/chronograf-v1.db "$backup_dir"/chronograf-v1.db
if [ $? -eq 0 ] && [ -f "$backup_dir/chronograf-v1.db" ]; then
echo "Backup completed successfully at $backup_dir."
else
echo "Backup failed!" >&2
exit 1
fi
else
echo "Skipping Chronograf..."
fi
;;
"kapacitor")
if [ "$enabled" == "true" ]; then
echo "Backing up Kapacitor..."
else
echo "Skipping Kapacitor..."
fi
;;
*)
echo "Unknown backup item: $name. Skipping..."
;;
esac
done

0 comments on commit 3b89ca7

Please sign in to comment.