Project Overview
This is a Bash-based tool for automated backups of Proxmox VE VM & CT configuration files using NFS storage. The project consists of a single executable script that operates as both a CLI tool and a systemd service daemon.
Core Architecture
Single Script Design: The entire application is contained in the pve-config-backup executable script (pve-config-backup:1), which serves multiple roles:
- CLI interface for installation, configuration, and status checking
- Systemd service daemon that runs inotify-based file watching
- Backup engine that copies .conf files to NFS storage locations
Key Components:
- Configuration Discovery (pve-config-backup:187):
get_conf_files_for_id()function finds all .conf files referencing VM/CT disks using regex pattern matching - NFS Backup Logic (pve-config-backup:207):
backup_nfs_configs()enumerates backup directories and copies configuration files - Inotify Daemon (pve-config-backup:294):
run_inotify_daemon()watches/etc/pve/nodes/*/qemu-serverand/etc/pve/nodes/*/lxcfor changes - Service Management (pve-config-backup:116): Functions for systemd service installation, start/stop operations
File Patterns: The script uses sophisticated regex patterns (pve-config-backup:190-196) to match both QEMU VM devices (scsi[0-9]+, virtio[0-9]+, etc.) and LXC container devices (rootfs, mp[0-9]+) when discovering configuration files.
Common Development Commands
Installation & Service Management:
# Install and start the service
./pve-config-backup install
# Check service status
./pve-config-backup status
# View backup information and logs
./pve-config-backup info
# Stop the service
./pve-config-backup stop
# Uninstall completely
./pve-config-backup uninstallDevelopment & Testing:
# Run shellcheck for linting (detected in codebase)
shellcheck pve-config-backup
# Test the daemon in foreground mode
./pve-config-backup daemon
# Create default configuration file
./pve-config-backup configConfiguration
Default Config Location: /etc/default/pve-config-backup
Log File: /var/log/pve-config-backup.log
Service File: /etc/systemd/system/pve-config-backup.service
Key Variables (pve-config-backup:40-43):
RSYNC_OPTS: Default rsync options for file copyingBACKUP_DIRS: Array of NFS mount patterns to search for VM/CT storageMAX_RETRIES/RETRY_WAIT: Boot-time waiting parameters for PVE directory availability
Dependencies
The script automatically installs required packages (pve-config-backup:158):
inotify-tools(for inotifywait)rsync(for file copying)util-linux(for mount/umount)
Development Notes
- This is a defensive security tool for backup purposes only
- Uses
set -euo pipefailfor strict error handling - Implements proper signal handling for graceful daemon shutdown
- All logging goes through the
log()function (pve-config-backup:52) with timestamps - The script waits up to 60 attempts for PVE directories to become available at boot (pve-config-backup:260)
What's Changed
- Update service unit documentation URL by @januszbak in #1
- Fix LXC config detection by @januszbak in #2
New Contributors
- @januszbak made their first contribution in #1
Full Changelog: https://github.com/open-e/pve-config-backup/commits/v1.00