Skip to content

Instantly share code, notes, and snippets.

@emrahoruc
Last active December 30, 2024 18:28
Show Gist options
  • Save emrahoruc/8d2a8620d2cf5129541c7b35586619a8 to your computer and use it in GitHub Desktop.
Save emrahoruc/8d2a8620d2cf5129541c7b35586619a8 to your computer and use it in GitHub Desktop.
Backup Script for Grafana Configuration and Data
#!/bin/bash
# Backup file name and location
BACKUP_DIR="/path/to/backup"
BACKUP_FILE="$BACKUP_DIR/grafana_backup_$(date +%Y%m%d_%H%M%S).zip"
# Files and directories to be backed up
GRAPHANA_DB="/var/lib/grafana/grafana.db"
GRAFANA_CONF="/etc/grafana/grafana.ini"
GRAFANA_PLUGINS="/var/lib/grafana/plugins"
# Create the backup directory if it does not exist
mkdir -p "$BACKUP_DIR"
# Start the backup and zip the files
echo "Starting backup..."
zip -r "$BACKUP_FILE" "$GRAPHANA_DB" "$GRAFANA_CONF" "$GRAFANA_PLUGINS"
# Success or error message
if [ $? -eq 0 ]; then
echo "Backup completed successfully. Backup file: $BACKUP_FILE"
else
echo "An error occurred during the backup."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment