Code Monkey home page Code Monkey logo

raspi's Introduction

raspberrypi

if raspberrypi.local links don't work, replace with local IP address (ifconfig) and look into bonjour/avahi issues.

homebridge | home-assistant

contents

this repo contains all my docs for my personal raspberry pi setup. rn it's running homebridge (for my nest mostly) and home assistant (for everything else). after accidentally splitting my sd card in half i decided to document the next setup process just to be safe. so here it is. i also wrote some scripts that make my life easier.

  • README.md - this. hi. i'm right here.
  • docker-compose.yml - my compose config. the only thing here you actually need to run this setup.
  • sync.sh - syncs the automatic backups to dropbox nightly
  • backup.sh - zips and uploads the entire HA/HB directories to dropbox monthly. also updates the docker images.

setup

ssh [email protected]
sudo apt update && sudo apt upgrade -y
curl -fsSL https://get.docker.com | sh
sudo apt-get install apt-transport-https ca-certificates software-properties-common -y
sudo usermod -aG docker pi
sudo curl https://download.docker.com/linux/raspbian/gpg
sudo nano /etc/apt/sources.list
# ⬆️ add `deb https://download.docker.com/linux/raspbian/ bullseye stable` on new line
sudo apt update && sudo apt upgrade -y && sudo apt autoremove
sudo systemctl start docker
sudo systemctl status docker # if it isn't working, try rebooting. running `dockerd` can also help
sudo mkdir /etc/homebridge && sudo mkdir /etc/homeassistant
# these two are just to get the docker-compose.yml
# you can also `nano docker-compose.yml` and copy and paste
git clone https://github.com/zanedb/raspi
cd raspi
docker compose up -d

configuring automatic backups

homebridge backs up nightly by default, and homeassistant can be configured to as well. then all you need is a cronjob that syncs them to your dropbox!

once you've setup rclone with both local and dropbox backends (rclone config), add sync.sh to your crontab (crontab -e). this runs every night at 5am, for example:

0 5 * * * /bin/sync.sh

backup backups

for no reason at all you could even have another backup going! this one could run less frequently but contain more data. could save you time in the future! plus you already wrote that script before you found an easier way! even better, it can update your docker images too! bcause why not! life is nothing if not experimental!

0 7 1 * * /bin/backup.sh

restoring from backup

this is what worked for me, your mileage may vary. hope it helps.

first, stop running containers:

docker compose down

homeassistant

scp core_20xx_xx_xx.tar [email protected]:/home/pi # copy HA backup over
ssh [email protected]
tar -xvf core_20xx_xx_xx.tar # note the -v because it's not .tar.gz
tar -xzf homeassistant.tar.gz # now it is
sudo rm -rf /etc/homeassistant
sudo cp -r data /etc/homeassistant
rm core_20xx_x_x.tar homeassistant.tar.gz && rm -rf data # cleanup
docker compose up -d # start again!

homebridge

if you're restoring from a homebridge-created backup to a docker image (like i was), it won't have the node_modules and won't install them for some reason. so you'll probably have to install the plugins in the dashboard, then reload your configuration so it finds your accessories. or maybe there's a better way? idk

scp homebridge-backup-xxxxxxxxxxx.tar.gz [email protected]:/home/pi # copy hb backup over
ssh [email protected]
tar -xzf homebridge-backup-xxxxxxxxxxx.tar.gz
sudo rm -rf /etc/homebridge && sudo cp -r storage /etc/homebridge
rm homebridge-backup-xxxxxxxxxxx.tar.gz plugins.json info.json && rm -rf storage # cleanup
docker compose up -d # woohoo!

raspi's People

Contributors

zanedb avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.