Created
April 4, 2024 16:01
-
-
Save btittelbach/d64342529a3e2f9246afcb5148258b67 to your computer and use it in GitHub Desktop.
homeassistant remote backup script
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/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