Still getting used to creating a wiki

phil 2025-01-05 19:03:06 +00:00
parent bc2c64aac7
commit b4ec8ec7a6

144
Home.md

@ -1,135 +1,149 @@
Home Assistant Backup Automation Scripts # Home Assistant Backup Automation Scripts
This wiki provides detailed documentation for the Home Assistant Backup Automation Scripts project, including configuration, usage instructions, and advanced features. The project contains two versions of the script to automate the backup process of your Home Assistant server. This wiki provides detailed documentation for the Home Assistant Backup Automation Scripts project, including configuration, usage instructions, and advanced features. The project contains two versions of the script to automate the backup process of your Home Assistant server.
Table of Contents Table of Contents
## Overview ## Overview
## Features
## Version 1 - Simple Backup with Cleanup
## Version 2 - Full Backup & Cleanup with Notifications
## Installation & Configuration
## Running the Script
## Scheduling Backups
## Notification Setup
## Retention Policies & Cleanup
## Storage Monitoring & Cleanup
## License & Disclaimer
Overview
The Home Assistant Backup Automation Scripts automate the process of creating, transferring, and managing backups of your Home Assistant server. These scripts enable seamless backup management by: The Home Assistant Backup Automation Scripts automate the process of creating, transferring, and managing backups of your Home Assistant server. These scripts enable seamless backup management by:
Creating backups on your Home Assistant server. * Creating backups on your Home Assistant server.
Transferring backups to your local machine for safekeeping. * Transferring backups to your local machine for safekeeping.
Cleaning up old backups automatically on both the Home Assistant server and the local machine based on retention policies. * Cleaning up old backups automatically on both the Home Assistant server and the local machine based on retention policies.
Features
Backup Creation: Automatically create backups on your Home Assistant server. ## Features
Backup Transfer: Copies backups to a local machine or any defined destination.
Old Backup Cleanup: Automatically removes old backups from both the Home Assistant server and local storage after a configurable retention period.
Storage Monitoring (V2 Only): The script checks the available storage on the Home Assistant server and removes old backups when storage falls below a defined threshold.
Optional Notifications: Integrates with ntfy or Discord for notifications about backup status (Version 1 only).
Version 1 - Full Backup & Cleanup with Notifications * Backup Creation: Automatically create backups on your Home Assistant server.
* Backup Transfer: Copies backups to a local machine or any defined destination.
* Old Backup Cleanup: Automatically removes old backups from both the Home Assistant server and local storage after a configurable retention period.
* Storage Monitoring (V2 Only): The script checks the available storage on the Home Assistant server and removes old backups when storage falls below a defined threshold.
* Optional Notifications: Integrates with ntfy or Discord for notifications about backup status (Version 2 only).
##### Version 1 - Simple Backup with Cleanup
Features of Version 1: Features of Version 1:
Complete Backup Workflow: Version 1 covers the full backup creation process, cleanup of old backups, and optional notifications via ntfy and Discord. * Simpler Backup Workflow: This version focuses on creating backups, transferring them to a local machine, and cleaning up old backups without the notification feature.
Backup Cleanup: Automatically removes backups older than the defined retention period on both the Home Assistant server and local machine.
Notification System: Sends notifications about backup success, failure, and other events via ntfy or Discord.
Version 1 Usage: Version 1 Usage:
Configure the script to connect to your Home Assistant server. - Configure the script for your Home Assistant SSH credentials and backup destination.
Set notification preferences to receive alerts for backup operations. - Set retention policies for old backups.
Run the script to automate backup creation, transfer, and cleanup. - Run the script to automatically manage backups and storage cleanup.
Optionally, schedule the script to run at regular intervals (e.g., daily, weekly). - Optionally, schedule the script to run periodically (e.g., daily).
Version 2 - Simple Backup with Cleanup ##### Version 2 - Full Backup & Cleanup with Notifications
Features of Version 2: Features of Version 2:
Simpler Backup Workflow: This version focuses on creating backups, transferring them to a local machine, and cleaning up old backups without the notification feature. * Complete Backup Workflow: Version 2 covers the full backup creation process, cleanup of old backups, and optional notifications via ntfy and Discord.
Storage Monitoring & Cleanup: If the available storage falls below 2GB, the script will remove old backups on the Home Assistant server based on a defined retention period to free up space. * Backup Cleanup: Automatically removes backups older than the defined retention period on both the Home Assistant server and local machine.
* Storage Monitoring & Cleanup: If the available storage falls below 2GB, the script will remove old backups on the Home Assistant server based on a defined retention period to free up space.
* Notification System: Sends notifications about backup success, failure, and other events via ntfy or Discord.
Version 2 Usage: Version 2 Usage:
Configure the script for your Home Assistant SSH credentials and backup destination. - Configure the script to connect to your Home Assistant server.
Set retention policies for old backups. - Set notification preferences to receive alerts for backup operations.
Run the script to automatically manage backups and storage cleanup. - Run the script to automate backup creation, transfer, and cleanup.
Optionally, schedule the script to run periodically (e.g., daily). - Optionally, schedule the script to run at regular intervals (e.g., daily, weekly).
## Installation & Configuration
Installation & Configuration
Step 1: Prerequisites Step 1: Prerequisites
Before you begin, ensure that you have the following prerequisites installed: Before you begin, ensure that you have the following prerequisites installed:
Bash shell (on both your local machine and the Home Assistant server). - Bash shell (on both your local machine and the Home Assistant server).
SSH access to your Home Assistant server.
Home Assistant with ha CLI tool installed. - SSH access to your Home Assistant server.
- Home Assistant with ha CLI tool installed.
Step 2: Script Configuration Step 2: Script Configuration
Open the script in a text editor and configure the following variables: Open the script in a text editor and configure the following variables:
HA_SSH_KEY: Path to your SSH private key for accessing Home Assistant.
HA_SSH_USER: SSH username (default: root).
HA_SSH_HOST: IP address or hostname of your Home Assistant server.
BACKUP_DEST: Path to your local backup storage.
Retention Policies: Configure how long to keep old backups on both the Home Assistant server and local machine.
Optional: Set up ntfy or Discord notifications (for Version 1).
Running the Script > HA_SSH_KEY: Path to your SSH private key for accessing Home Assistant.
> HA_SSH_USER: SSH username (default: root).
> HA_SSH_HOST: IP address or hostname of your Home Assistant server.
> BACKUP_DEST: Path to your local backup storage.
> Retention Policies: Configure how long to keep old backups on both the Home Assistant server and local machine.
> Optional: Set up ntfy or Discord notifications (for Version 2).
## Running the Script
After configuring the script, make it executable: After configuring the script, make it executable:
```
chmod +x home_assistant_backup.sh chmod +x home_assistant_backup.sh
```
Run the script using the following command: Run the script using the following command:
```
./home_assistant_backup.sh ./home_assistant_backup.sh
```
This will: This will:
Create a backup on the Home Assistant server. * Create a backup on the Home Assistant server.
Transfer the backup file to your local machine. * Transfer the backup file to your local machine.
Clean up old backups based on the defined retention period. * Clean up old backups based on the defined retention period.
Scheduling Backups ## Scheduling Backups
To automate the backup process, you can schedule the script to run at regular intervals using cron. For example, to run the script daily at midnight: To automate the backup process, you can schedule the script to run at regular intervals using cron. For example, to run the script daily at midnight:
```
crontab -e crontab -e
```
Add the following line: Add the following line:
```
0 0 * * * /path/to/home_assistant_backup.sh 0 0 * * * /path/to/home_assistant_backup.sh
```
Notification Setup ## Notification Setup
Version 1 (Optional Notifications):
##### Version 1 (No Notifications):
Version 1 does not include notification functionality, but you can customize it further if needed.
##### Version 2 (Optional Notifications):
You can configure ntfy or Discord notifications to receive alerts when a backup is created, failed, or completed. You can configure ntfy or Discord notifications to receive alerts when a backup is created, failed, or completed.
ntfy Setup: - ntfy Setup: Enable ntfy notifications by setting `NTFY_ENABLED=true` and configuring the `NTFY_SERVER` and `NTFY_TOPIC` variables.
Enable ntfy notifications by setting NTFY_ENABLED=true and configuring the NTFY_SERVER and NTFY_TOPIC variables. - Discord Setup: Enable Discord notifications by setting `DISCORD_ENABLED=true` and providing the `DISCORD_WEBHOOK_URL`.
Discord Setup:
Enable Discord notifications by setting DISCORD_ENABLED=true and providing the DISCORD_WEBHOOK_URL.
Version 2 (No Notifications):
Version 2 does not include notification functionality, but you can customize it further if needed. ## Retention Policies & Cleanup
Retention Policies & Cleanup
The script allows you to define retention policies for both local and remote backups: The script allows you to define retention policies for both local and remote backups:
Local Backup Cleanup: Deletes backups older than a configurable number of days (default is 30 days). * Local Backup Cleanup: Deletes backups older than a configurable number of days (default is 30 days).
Remote Backup Cleanup: Deletes backups on the Home Assistant server that are older than a specified retention period (default is 30 days). * Remote Backup Cleanup: Deletes backups on the Home Assistant server that are older than a specified retention period (default is 30 days).
## Storage Monitoring & Cleanup
These cleanup policies help maintain storage space and ensure that outdated backups are removed automatically. These cleanup policies help maintain storage space and ensure that outdated backups are removed automatically.
Storage Monitoring & Cleanup Storage Monitoring & Cleanup
In Version 2, we introduced a new feature for storage monitoring. The script checks the available storage on the Home Assistant server and, if it falls below 2GB, it will automatically remove old backups to free up space. You can configure the number of days' worth of backups to remove if storage is running low. In Version 2, we introduced a new feature for storage monitoring. The script checks the available storage on the Home Assistant server and, if it falls below 2GB, it will automatically remove old backups to free up space. You can configure the number of days' worth of backups to remove if storage is running low.
License & Disclaimer
## License & Disclaimer
The software is provided "as-is" without any warranties or guarantees of any kind. The software is provided "as-is" without any warranties or guarantees of any kind.