diff --git a/backup/backup.sh b/backup/backup.sh index 295de20..3214871 100644 --- a/backup/backup.sh +++ b/backup/backup.sh @@ -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" @@ -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