subDesTagesMitExtraKaese 7d45bc1c42 add borg compact command | hai 3 meses | |
---|---|---|
.env.example | hai 3 meses | |
.gitignore | hai 3 meses | |
README.md | hai 3 meses | |
check_battery.sh | hai 3 meses | |
grafana_dashboard.json | hai 3 meses | |
log_to_influx.sh | hai 3 meses | |
mount_hdd.sh | hai 3 meses | |
power_off_hdd.sh | hai 3 meses | |
power_on_hdd.sh | hai 3 meses | |
run_backup.sh | hai 3 meses | |
run_backup_process.sh | hai 3 meses | |
unmount_hdd.sh | hai 3 meses |
This project automates the process of running Borg backups on a Linux server. It includes scripts for managing external HDD power, mounting and unmounting the HDD, running the backup, and logging the results to InfluxDB.
.
├── power_on_hdd.sh # Script to power on the external HDD
├── power_off_hdd.sh # Script to power off the external HDD
├── mount_hdd.sh # Script to mount the external HDD
├── unmount_hdd.sh # Script to unmount the external HDD
├── check_battery.sh # Script to check battery level before running the backup
├── run_backup.sh # Script to execute the Borg backup
├── run_backup_process.sh # Main script to automate the backup process
├── log_to_influx.sh # Script to log the backup results to InfluxDB
├── grafana_dashboard.json # Example Grafana dashboard for monitoring
├── .env # Environment variables (ignored by Git)
├── .env.example # Example environment variables file
├── .gitignore # Files and directories to be ignored by Git
└── keys/ # Directory for SSH keys (ignored by Git)
Clone the repository:
git clone https://github.com/yourusername/borg-backup-automation.git
cd borg-backup-automation
Set up your environment:
Copy the example .env
file:
cp .env.example .env
Edit .env
with your specific configuration.
Ensure all scripts have executable permissions:
chmod +x *.sh
The configuration is managed via the .env
file. Below are the key variables you need to configure:
Home Assistant Details:
HA_URL
: URL of your Home Assistant instance.HA_TOKEN
: Long-lived access token for Home Assistant.HDD_SWITCH_ENTITY
: Home Assistant entity ID for controlling HDD power.BATTERY_SENSOR_ENTITY
: Home Assistant entity ID for battery level monitoring.MIN_BATTERY_LEVEL
: Minimum battery percentage required to run the backup.Server Details:
SERVER_USER
: SSH user for the remote server.SERVER_IP
: IP address of the remote server.SSH_KEY
: Path to the SSH private key.SSH_PORT
: SSH port (default: 22).HDD Mount Details:
HDD_DEVICE
: Device path for the external HDD (e.g., /dev/sdb1
).MOUNT_POINT
: Mount point for the external HDD (e.g., /mnt/external_hdd
).Borg Backup Details:
REPOSITORY
: Path to the Borg backup repository on the mounted HDD.SOURCE_DIRECTORIES
: Directories to back up.PASSPHRASE
: Passphrase for the Borg repository.Logging Details:
INFLUXDB_URL
: URL of your InfluxDB instance.INFLUXDB_ORG
: Organization name for InfluxDB.INFLUXDB_BUCKET
: InfluxDB bucket for storing backup logs.INFLUXDB_TOKEN
: Authentication token for InfluxDB.Run the main backup process script:
./run_backup_process.sh
This script will:
Contributions are welcome! Please submit pull requests or open issues to suggest changes or report bugs.
This project is licensed under the MIT License. See the LICENSE file for details.