Last active
January 9, 2024 10:53
-
-
Save sirtawast/1c783020b52a6f342d1a9fe5f7678fa7 to your computer and use it in GitHub Desktop.
Simple SSH script to backup docker composed Home Assistant data to AWS S3 on my Raspberry Pi 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
# Assumes aws-cli installed and configured | |
# Use crontab or whatever you like to automate | |
HA_BACKUP_DATE=$(date +"%m-%d") | |
HA_S3_BUCKET_PATH="my-ha-backups/latest/whatever" | |
cd /home/$USER/homeassistant | |
docker compose stop | |
cd .. | |
tar -czvf ha-backup-$HA_BACKUP_DATE.zip homeassistant/data | |
aws s3 cp "ha-backup-$HA_BACKUP_DATE.zip" "s3://$HA_S3_BUCKET_PATH/ha-backup-$HA_BACKUP_DATE.zip" --acl=private | |
cd /home/$USER/homeassistant | |
docker compose start -d | |
rm -f "../ha-backup-$HA_BACKUP_DATE.zip" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment