-
-
Save mika/085b0cdc805ef373fd3f743f764a93b4 to your computer and use it in GitHub Desktop.
homeassistant remote backup script
This file contains hidden or 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/zsh | |
HOST=homeassistant.lan | |
snapname=$(date +%Y-%m-%d_%T_homeassistant_autosnap) | |
slugname=$(ssh $HOST "source /etc/profile; ha backups new --name \"${snapname}\" " | tail -n 1 ) || exit 1 | |
[[ -z $slugname ]] && exit 2 | |
echo $slugname | grep -q "slug: " || exit 3 | |
slugname=$(echo $slugname | cut -c 7-) | |
snapfilename=backup/${slugname}.tar | |
scp ${HOST}:${snapfilename} "./${snapname}.tar" || exit 4 | |
ssh $HOST "source /etc/profile; ha backups remove \"${slugname}\"" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment