Created
January 5, 2022 17:45
-
-
Save orangecoding/5c06fc71eaee5d8dc6385abc5dea6730 to your computer and use it in GitHub Desktop.
Homebridge backup from Terminal
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 | |
# | |
# This script requires the "jq" package to be installed. | |
# Linux: sudo apt-get install jq | |
# macOS: brew install jq | |
# | |
USERNAME=YOUR_ADMIN_USERNAME | |
PASSWORD=YOUR_ADMIN_PASSWORD | |
UI_HOST=http://localhost:8581 | |
BACKUP_FILE_PATH="./" | |
BACKUP_FILE_NAME="backup-$(date '+%Y-%m-%d').tar.gz" | |
# Get Access Token | |
ACCESS_TOKEN=$(curl -s "$UI_HOST/api/auth/login" \ | |
-H 'Content-Type: application/json' \ | |
--data-binary "{\"username\":\"$USERNAME\",\"password\":\"$PASSWORD\"}" \ | |
| jq -r .access_token) | |
# Download Backup | |
curl -s "$UI_HOST/api/backup/download" \ | |
-H "Authorization: bearer $ACCESS_TOKEN" \ | |
-o "$BACKUP_FILE_PATH/$BACKUP_FILE_NAME" | |
echo "Backup saved to $BACKUP_FILE_PATH/$BACKUP_FILE_NAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment