# AdGuardHome Config Backup Script This project provides a Bash script to back up the AdGuardHome configuration file (`AdGuardHome.yaml`) from multiple remote servers via SSH. The script supports: - Backup of multiple servers defined in a `.env` file - Timestamped backup files named using the server's hostname - Logging of each backup session - Optional notifications via [ntfy.sh](https://ntfy.sh/) and Discord --- ## ๐Ÿ“ฆ Features - SSH key authentication - Environment-based configuration - Per-host backup with hostname and timestamp - Automatic log file generation - Optional failure/success notifications --- ## ๐Ÿ› ๏ธ Requirements - Bash - `ssh` and `scp` installed - A valid SSH private key - Optional: `curl` (for notifications) --- ## ๐Ÿงพ Setup ### 1. Clone the repository ```bash git clone https://github.com/youruser/adguard-backup-script.git cd adguard-backup-script ``` ### 2. Configure the `.env` file Copy and edit the sample `.env` file: ```env # SSH Settings HA_SSH_KEY="$HOME/.ssh/id_rsa" HA_SSH_USER="youruser" # Backup destination (local path) BACKUP_DEST="/your/backup/directory" # Remote config path (optional override) REMOTE_FILE="/opt/AdGuardHome/AdGuardHome.yaml" # List of remote servers (space-separated) SERVER_LIST="server1.example.com server2.example.com 192.168.1.100" # Notification options (optional) NTFY_ENABLED=true NTFY_SERVER="https://ntfy.yourdomain.com" NTFY_TOPIC="adguard-backups" DISCORD_ENABLED=true DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/..." ``` ### 3. Make the script executable ```bash chmod +x backup_adguard.sh ``` ### 4. Run the backup ```bash ./backup_adguard.sh ``` --- ## ๐Ÿ—‚๏ธ Backup Output - Files saved to: `$BACKUP_DEST` - Naming convention: `AdGuardHome.yaml--` - Example: `AdGuardHome.yaml-server1-2025-06-23_14-45-01` --- ## ๐Ÿ”” Notifications (Optional) ### ntfy - Configure `NTFY_ENABLED=true`, `NTFY_SERVER`, and `NTFY_TOPIC` in your `.env`. ### Discord - Set `DISCORD_ENABLED=true` and supply your `DISCORD_WEBHOOK_URL`. --- ## ๐Ÿงช Sanity Checks The script will validate: - SSH key path - SSH user - Backup destination - Server list - Notification credentials (if enabled) --- ## ๐Ÿ“œ Log Files Each run generates a log file: - Location: `$BACKUP_DEST` - Format: `backup-.log` Example: ``` backup-2025-06-23_14-45-01.log ``` --- ## ๐Ÿ’ก Tips - Use cron to automate the script (e.g., daily backups). - Ensure your SSH key is authorized on all target servers. - Monitor logs or enable notifications for unattended runs. --- ## ๐Ÿ“„ License MIT License --- ## ๐Ÿค Contributing Feel free to fork, submit PRs, or suggest improvements!