From 8b645e5edce3595f12b3796368f1ca27967b0a7e Mon Sep 17 00:00:00 2001 From: Phil Date: Thu, 1 Feb 2024 23:26:53 +0000 Subject: [PATCH] Updated script to fix a typo in auto cleanup where .tar was duplicated and changed the destination file name so the date is before the slug name to help with data organization. --- ha-backup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ha-backup.sh b/ha-backup.sh index 9b6e721..31c7328 100644 --- a/ha-backup.sh +++ b/ha-backup.sh @@ -14,9 +14,9 @@ BACKUP_OUTPUT=$(ssh -i "$HA_SSH_KEY" "$HA_SSH_USER@$HA_SSH_HOST" "ha backup new BACKUP_SLUG=$(echo "$BACKUP_OUTPUT" | awk '/slug:/ {print $2}') # Copy the backup file from Home Assistant to your local machine -scp -i "$HA_SSH_KEY" "$HA_SSH_USER@$HA_SSH_HOST:/backup/${BACKUP_SLUG}.tar" "$BACKUP_DEST/${BACKUP_SLUG}_$(date '+%Y-%m-%d_%H-%M-%S').tar" +scp -i "$HA_SSH_KEY" "$HA_SSH_USER@$HA_SSH_HOST:/backup/${BACKUP_SLUG}.tar" "$BACKUP_DEST/$(date '+%Y-%m-%d_%H-%M-%S')_${BACKUP_SLUG}.tar" # Clean up old backups if needed (adjust the number of days to keep) find "$BACKUP_DEST" -name '*.tar' -mtime +30 -exec rm {} \; -echo "Backup completed successfully: $BACKUP_DEST/${BACKUP_SLUG}_$(date '+%Y-%m-%d_%H-%M-%S').tar.tar" +echo "Backup completed successfully: $BACKUP_DEST/$(date '+%Y-%m-%d_%H-%M-%S')_${BACKUP_SLUG}.tar"