These scripts automate the backup process for Home Assistant servers, enabling you to create, transfer, and manage backups. The backups are securely transferred from the Home Assistant server to your local machine, with options for cleaning up old backups based on configurable retention periods.
Go to file
2025-01-05 18:16:51 +00:00
V1 In the updated version of the script (V2), we've added a critical feature that checks the available storage on the Home Assistant server. If the available storage falls below 2GB, the script will automatically remove a defined number of days' worth of old backups, ensuring that the system doesn't run out of space. This storage threshold is configurable, and you can adjust the number of days' worth of backups to be retained according to your needs. This feature is designed to help manage storage effectively—because, as we all know, storage isn't infinite! 😄 Additionally, both V1 and V2 of the scripts now include much more detailed and comprehensive README.md files, offering users a clearer understanding of the setup, configuration, and usage. The documentation includes step-by-step instructions, explanations of configurable options, and tips for maintaining a reliable backup routine for your Home Assistant server. 2025-01-05 18:16:51 +00:00
V2 In the updated version of the script (V2), we've added a critical feature that checks the available storage on the Home Assistant server. If the available storage falls below 2GB, the script will automatically remove a defined number of days' worth of old backups, ensuring that the system doesn't run out of space. This storage threshold is configurable, and you can adjust the number of days' worth of backups to be retained according to your needs. This feature is designed to help manage storage effectively—because, as we all know, storage isn't infinite! 😄 Additionally, both V1 and V2 of the scripts now include much more detailed and comprehensive README.md files, offering users a clearer understanding of the setup, configuration, and usage. The documentation includes step-by-step instructions, explanations of configurable options, and tips for maintaining a reliable backup routine for your Home Assistant server. 2025-01-05 18:16:51 +00:00
LICENSE Initial commit 2024-02-01 23:13:23 +00:00
README.md In the updated version of the script (V2), we've added a critical feature that checks the available storage on the Home Assistant server. If the available storage falls below 2GB, the script will automatically remove a defined number of days' worth of old backups, ensuring that the system doesn't run out of space. This storage threshold is configurable, and you can adjust the number of days' worth of backups to be retained according to your needs. This feature is designed to help manage storage effectively—because, as we all know, storage isn't infinite! 😄 Additionally, both V1 and V2 of the scripts now include much more detailed and comprehensive README.md files, offering users a clearer understanding of the setup, configuration, and usage. The documentation includes step-by-step instructions, explanations of configurable options, and tips for maintaining a reliable backup routine for your Home Assistant server. 2025-01-05 18:16:51 +00:00

Home Assistant Backup Automation Scripts

These scripts automate the backup process for Home Assistant servers, enabling you to create, transfer, and manage backups. The backups are securely transferred from the Home Assistant server to your local machine, with options for cleaning up old backups based on configurable retention periods.

Overview

Features:

  • Backup Creation: Automates the process of creating backups on your Home Assistant server.
  • Backup Transfer: Transfers the generated backups to a local machine for safekeeping.
  • Old Backup Cleanup: Automatically cleans up old backups on both the Home Assistant server and local machine after a specified retention period.
  • Notification Support (Optional): Configure ntfy or Discord notifications to alert you about the backup status (available in the first script version).

Two Versions of the Script:

  1. Version 1: Simple Backup with Cleanup
    A simpler version that creates a backup, copies it to your local machine, and performs a basic cleanup of old backups locally. No notification system is included in this version.

  2. Version 2: Full Backup and Cleanup with Notifications
    This version includes backup creation, local and remote cleanup of old backups, and optional notifications via ntfy and Discord. It also checks for available disk space before cleaning up old backups.

Requirements

Both scripts require the following to function correctly:

  • Bash shell (on your local machine and Home Assistant server)
  • SSH access to the Home Assistant server
  • scp and ssh tools
  • Home Assistant installed on the server with the ha CLI tool
  • Optional: Access to a notification service (for Version 1)

Configuration

Before running either script, you need to set up a few configuration parameters. These include SSH credentials, backup destination paths, and notification settings.

  • HA_SSH_KEY: Path to your private SSH key for accessing the Home Assistant server.
  • HA_SSH_USER: The SSH username (default is root).
  • HA_SSH_HOST: The IP address or hostname of your Home Assistant server.
  • BACKUP_DEST: Path to the directory where backups will be saved locally.
  • Retention Settings: You can configure how long old backups are kept before they are deleted (default is 30 days for local and remote backups).
  • Optional: Set up ntfy or Discord notifications to receive alerts when backups are created or when errors occur.

How to Use

Step 1: Configure the Script

Open the script file in a text editor and set the following variables:

  • SSH credentials (HA_SSH_KEY, HA_SSH_USER, HA_SSH_HOST)
  • Backup destination path (BACKUP_DEST)
  • Notification settings (optional)

Step 2: Make the Script Executable

After configuring the script, make it executable by running:

chmod +x home_assistant_backup.sh

Disclaimer

The software is provided "as-is" without any warranties or guarantees of any kind.

By using this script, you acknowledge and agree that:

  • No Warranty: The script is provided without any warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. The entire risk arising out of the use or performance of the script remains with you.

  • Data Loss: The author cannot be held responsible for any data loss, damage to your system, or any other kind of loss resulting from the use of this script. You are solely responsible for backing up your data and ensuring the integrity of your systems before using the script.

  • Use at Your Own Risk: You are using this script at your own risk. The author shall not be liable for any damages, including but not limited to direct, indirect, incidental, special, consequential, or punitive damages, arising out of the use of or inability to use the script.

  • No Support: The script is provided "as-is" with no formal support or maintenance. The author does not provide any guarantees of continued functionality, updates, or support.

  • Modifications and Redistribution: If you modify or redistribute the script, you do so at your own risk. You are solely responsible for ensuring that any modifications or redistributed versions do not cause harm or violate any laws.

By using or modifying this script, you agree to indemnify and hold harmless the author from any and all claims, damages, liabilities, and expenses arising from your use or modification of the script.


Use of this script is subject to the terms above. If you do not agree with this disclaimer, you should not use the script.