Skip to content

Instantly share code, notes, and snippets.

@fragolinux
Last active July 29, 2019 23:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save fragolinux/e66148f3cf7244130058fb626c6b7c67 to your computer and use it in GitHub Desktop.
Save fragolinux/e66148f3cf7244130058fb626c6b7c67 to your computer and use it in GitHub Desktop.
simple but effective node-red setup backup script
#!/bin/bash
cd
# useful vars
DATE=$(date +"%Y%m%d%H%M")
WHERE=~/backup/$DATE
# create dated backup folders
mkdir -p $WHERE/{sqlite,nodered,etc}
# safely backup sqlite db
sqlite3 ~/dbs/iot.db ".backup $WHERE/sqlite/iot.db"
# backup json and js files
cp -a ~/.node-red/{*.json,*.js,public,lib} $WHERE/nodered
# backup main config folders/files
sudo cp -a /etc/{mosquitto,hosts,hostname,rc.local} $WHERE/etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment