This Python script automates the backup process using PiKVM for remote power management, Hyper-V for virtual machine monitoring, and Restic for secure data backups. It's designed to efficiently manage backups while minimizing power consumption when the backup PC is not in use.
- Remote Power Management: Utilizes PiKVM API to power on/off the backup PC remotely.
- Virtual Machine Monitoring: Monitors a specified VM running on Hyper-V to ensure it's active before starting backups.
- Restic Integration: Automates backups using Restic to securely store data on the remote PC.
- Configuration File: Uses
config.ini
for easy customization of IP addresses, credentials, and backup settings.
- Python 3.x: Make sure Python 3.x is installed on your system.
- Restic: Install Restic on your backup PC and configure it with a repository for storing backups.
- PiKVM Setup: Ensure PiKVM is configured and accessible for remote management.
-
Clone the repository:
git clone https://github.com/capruro/remote-backup-pikvm-restic.git cd remote-backup-pikvm-restic
-
Rename
config.ini.sample
toconfig.ini
. -
Edit
config.ini
and configure the following parameters:- Replace
your_pikvm_ip
with the IP address of your PiKVM. - Replace
your_vm_ip
with the IP address of your VM running on Hyper-V. - Configure
backup_target
with the path to the data you want to back up. - Update
password_file
with the path to your Restic password file.
- Replace
Run the script using Python:
python backup_script.py
The script will:
- Check the current state of the backup PC using PiKVM.
- Power on the PC if it's off.
- Monitor the specified VM on Hyper-V and wait for it to start.
- Initiate a Restic backup to securely store data on the backup PC.
- Optionally power off the PC after backup completion, depending on its initial state.
Contributions are welcome! Feel free to open issues for feedback or submit pull requests with improvements.