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.

This commit is contained in:
Phil 2024-02-01 23:26:53 +00:00
parent 8df1a993c1
commit 8b645e5edc

View File

@ -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"