Giter Site home page Giter Site logo

wled-backup's Introduction

WLED Backup (wled-backup)

standard-readme compliant .github/workflows/ci.yaml Go version Go Report

Simple CLI tool to backup presets & configuration from a WLED device.

Table of Contents

Background

I put a lot of effort in getting my presets right for all of my WLED devices. The cheap ESP8266's I buy from AliExpress aren't resistant to failure however and reflashing WLED on a new ESP means that I would have to recreate my presets from scratch. Luckily WLED's JSON API exposes an endpoint to retrieve your presets & configuration as JSON files.

This tool does nothing more than calling that endpoint and writing it to a file on the system in parallel. This way you can backup your files via e.g a cronjob.

It's also possible to reupload these files across host and syncing the presets if you'd want that. This tool however does not currently support that.

Install

Download the latest release binary for your platform from the releases page. Optionally rename it if you want but this is not required.

Usage

Run the export command and pass a host or a list of (comma separated) hosts.

# A single host
$ ./wled-backup_linux_x64 export --hosts=192.168.1.12

# Multiple hosts
$ ./wled-backup_linux_x64 export --hosts=192.168.1.12,192.168.1.177

# mDNS works too, you can mix and match
$ ./wled-backup_linux_x64 export --hosts=wled-tv.local,192.168.1.177

By default this will output the backup files in the current folder. You can optionally specify an output directory with the --outputDir flag:

$ ./wled-backup_linux_x64 export --hosts=192.168.1.12,192.168.1.177 --outputDir=/home/user/wled_backups

Development

To build from source make sure you have the following dependencies installed:

  • GNU Make 3.81+
  • asdf

The version of Go is determined by .tool-versions, the configuration file for asdf. To install the correct version determined by the repository run the following command:

$ asdf install

You can then use the provided Make targets to build for all or specific architectures:

# Build for 64 bit (Linux, macOS Intel, Windows)
$ make build_x64

# Build for ARM (Linux, Raspberry Pi, macOS M1)
$ make build_x64

# Build all artifacts
$ make build

The built artifacts will then be available in the ./bin/ folder:

bin
├── wled-backup_linux_armv6
├── wled-backup_linux_armv7
├── wled-backup_linux_x64
├── wled-backup_mac_arm64
├── wled-backup_mac_x64
└── wled-backup_win_x64.exe

License

Unlicense

For more info, see LICENSE file

wled-backup's People

Contributors

thibmaek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

alienlights

wled-backup's Issues

Great Utility - Does not seem to work with Sound Reactive WLed v12.0

Hi

Works fine on WLED v13.01 on ESP8266 boards

However on Sound Reactive WLED 12.0 although the command runs with no error - no files are created in the current directory

This was run using Linux version of your utility ...

Is this to do with it being an older version than the current or is it due to being sound reactive WLed?

Hope you can shed some light on this

[BUG] Multiple Hosts + Solution Wrapper Script

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.