Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Multiple Hosts + Solution Wrapper Script #2

Open
Ramalama2 opened this issue May 10, 2023 · 1 comment
Open

[BUG] Multiple Hosts + Solution Wrapper Script #2

Ramalama2 opened this issue May 10, 2023 · 1 comment

Comments

@Ramalama2
Copy link

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
  • As you see it dumps wled-buero, as wled-zimmer.

  • It doesn't matter if i use the IP or Hostname.

  • Workaroud Script

#/bin/bash

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" "$Backup_DIR/${currtime}_$host_name.config.json"
  mv "$Backup_DIR/$host_name.presets.json" "$Backup_DIR/${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
Copy link
Author

Ramalama2 commented May 17, 2023

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
Simple script to Automate Wled Backups. Contribute to Ramalama2/wled-backup-script development by creating an account on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant