thibmaek / wled-backup

Simple CLI tool to backup presets & configuration from a WLED device
The Unlicense
12 stars 1 forks source link

[BUG] Multiple Hosts + Solution Wrapper Script #2

Open Ramalama2 opened 1 year ago

Ramalama2 commented 1 year ago

If you backup multiple wled instances, your executable dumps always the last instance:

# ./scripts/wled-backup_linux_x64 export --hosts=wled-zimmer.user.mydomain.eu,wled-buero.user.mydomain.eu --outputDir=/root/Backups/WLED

Output:

Downloading config for host 'wled-buero.user.mydomain.eu'
Downloading config for host 'wled-buero.user.mydomain.eu'
Downloading presets for host 'wled-buero.user.mydomain.eu'
Downloading presets for host 'wled-buero.user.mydomain.eu'

Written Files:

# ls -l Backups/WLED/
total 18
-rw-r--r-- 1 root root 2080 May 10 12:25 wled-buero.config.json
-rw-r--r-- 1 root root 5880 May 10 12:25 wled-buero.presets.json
-rw-r--r-- 1 root root 2080 May 10 12:25 wled-zimmer.config.json
-rw-r--r-- 1 root root 5880 May 10 12:25 wled-zimmer.presets.json

Backup_DIR=/root/Backups/WLED wled_backup_exec=/root/scripts/wled-backup_linux_x64 currtime=$(TZ="Europe/Berlin" date +"%Y%m%d-%H%M")

Array of hosts

hosts=("wled-buero.user.mydomain.eu" "wled-zimmer.user.mydomain.eu")

Loop over each host

for host in "${hosts[@]}"; do

Extract the host name from the full address

host_name=$(echo "$host" | cut -d'.' -f1)

Execute the backup

$wled_backup_exec export --hosts="$host" --outputDir="$Backup_DIR"

Rename the configuration and presets files

mv "$Backup_DIR/$host_name.config.json" "$BackupDIR/${currtime}$host_name.config.json" mv "$Backup_DIR/$host_name.presets.json" "$BackupDIR/${currtime}$host_name.presets.json" done


- The script will rename the files additionally to include a timestamp. I need that anyway to dump daily with a cronjob the Backups into the same directory.

Cheers
Ramalama2 commented 1 year ago

Since i found it a bit stupid to use an 5.8mb executable for that task, ill did it with a simple bash script: https://github.com/Ramalama2/wled-backup-script

Cheers

GitHub
GitHub - Ramalama2/wled-backup-script: Simple script to Automate Wled Backups
Simple script to Automate Wled Backups. Contribute to Ramalama2/wled-backup-script development by creating an account on GitHub.