Last active
December 30, 2024 18:28
-
-
Save emrahoruc/8d2a8620d2cf5129541c7b35586619a8 to your computer and use it in GitHub Desktop.
Backup Script for Grafana Configuration and Data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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