# πŸ’Ύ PVE Rsync Backup Pro (Bash) --- ### πŸš€ The Problem Standard Proxmox backup solutions often leave temporary dumps on the node or lack flexibility in how files are transferred to offsite storage. In high-density ISP or homelab environments, you need a surgical approach: back up a specific VM, transfer it immediately, and leave zero traces on the source node. ### πŸ›  The Solution This script is a "surgical" automation layer for Proxmox vzdump. Unlike generic scripts, it **parses the real-time log** to identify the exact archive path, transfers it via `rsync`, and performs a verified cleanup. It’s designed for those who value storage efficiency and data portability. ### πŸ”‘ Key Features: * **Precision Extraction:** Uses `awk` to grab the exact `.vma.zst` path from the vzdump output. No more "guessing" based on timestamps. * **Surgical Cleanup:** Automatically removes the remote dump and its log file from the PVE node only after a successful transfer. * **Safety Triggers:** Built-in validation ensures the script never executes `rm` on directories or incorrect file types. * **Rsync-Powered:** Uses `files-from` logic for atomic transfers of both VM configurations and disk images. * **ISP-Grade Logging**: Detailed logs with timestamping, console output, and integration with `syslog` (via `logger`). * **Node Whitelisting:** Verification of the node name to prevent accidental execution on the wrong host. ### πŸ“¦ Dependencies & Requirements | Component | Role | Requirement | | :--- | :--- | :--- | | **SSH Keys** | Authentication | Passwordless root/sudo access to PVE | | **Sudo** | Permissions | Access to `qm`, `vzdump`, and `rm` in the **sudoers** of the PVE node | | **Rsync** | Transfer | Installed on both Local & Remote nodes | | **Mail** | Reporting | `mailutils` or `bsd-mailx` (optional) | ### πŸ“– Usage 1. Initial Setup: Clone the script, make it executable and create your configuration file: ```bash chmod +x pve-rsync-backup.sh cp pve-rsync-backup.conf.example pve-rsync-backup.conf ``` 2. Configure: Edit `pve-rsync-backup.conf` with your SSH keys, allowed nodes, and rsync modules. 3. Run the Backup task or add it to the `crontab`: ```bash # Usage: ./pve-rsync-backup.sh ./pve-rsync-backup.sh 192.168.1.10 101 ``` ### πŸ“ Backup Structure The script organizes backups by node and VM ID for easy navigation: ``` /backups/ └── node-name/ <-- Node name used from 192.168.1.10 └── vm101/ <-- VM ID β”œβ”€β”€ 20260415_1453/ <-- Current backup β”‚ β”œβ”€β”€ 101-filelist.txt <-- Rsync list to backup β”‚ β”œβ”€β”€ Local_README.md <-- Short instruction to restore VM from dump β”‚ β”œβ”€β”€ etc/ β”‚ β”‚ └── pve/ β”‚ β”‚ └── nodes/ β”‚ β”‚ └── node-name/ β”‚ β”‚ └── qemu-server/ β”‚ β”‚ └── 101.conf <-- VM conf file β”‚ └── storage-name/ β”‚ └── dump/ β”‚ β”œβ”€β”€ vzdump-qemu-101...vma.zst <-- VM dump file β”‚ └── vzdump-qemu-101...log <-- VM dump log └── logs/ <-- Historical logs └── 20260415_1453-backup.log <-- Current backup task log ``` --- ### βš–οΈ License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. ### ⚠️ Disclaimer: **Use at your own risk! This script performs `sudo rm` operations on remote hosts. Always test in a staging environment (e.g., on a non-critical VM) before adding to production crontab.**