There's a number of discussions on the forum about how to backup PVE itself, mainly focussed on the config files.
Being a scripting tard I've asked our friend ChatGTP to help me making a simple script. There's probably a way better method, but this covers my needs.
So for those looking for something similar, or something to start with, here it goes:
Being a scripting tard I've asked our friend ChatGTP to help me making a simple script. There's probably a way better method, but this covers my needs.
So for those looking for something similar, or something to start with, here it goes:
Here's your complete, no-nonsense setup guide to secure, automated Proxmox PVE config backup with remote sync, using a locked-down
backupuser and rsync over SSH.This is for backing up only configuration files (host, VM, and LXC), not full VM images. You’ll end up with a secure and maintainable system that mirrors your backups to a remote box, auto-cleans, and doesn’t require remote shell access.
GOAL
You will:
- Back up all important Proxmox config files
- Sync them to a remote server over SSH using
rsync - Lock down the remote user (
backupuser) to only accept file uploads - Automatically prune old local and remote backups
- Run the whole thing via cron
️ SYSTEM SETUP
1.
Create backupuser on the remote server
backupuser on the remote serverOn remote server (192.168.1.100):
Code:
sudo adduser --disabled-password --shell /usr/sbin/nologin backupuser
sudo mkdir -p /backups/proxmox
sudo chown backupuser:backupuser /backups/proxmox
sudo chmod 700 /backups/proxmox
This creates a no-shell, upload-only user that owns its backup directory.
2.
Generate SSH key on Proxmox
On your Proxmox host:
Code:
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -C "proxmox-backup"
- Press enter through all prompts
- Do not set a passphrase
3.
Set up key-based login to backupuser
backupuserOn Proxmox:
Code:
ssh-copy-id -i ~/.ssh/id_ed25519.pub backupuser@192.168.1.100
Then on the remote server:
Edit
~backupuser/.ssh/authorized_keys and wrap the key with restrictions:
Code:
command="rsync --server --sender -logDtprze.iLsfxC . /",no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-pty ssh-ed25519 AAAA... proxmox-backup
Replace
ssh-ed25519 AAAA...with the actual key from the.pubfile.
This allows only
rsync in upload mode. User cannot execute arbitrary commands or log in interactively.4.
Install rsync on both machines
rsync on both machinesMake sure it's available:
Code:
apt update && apt install rsync -y
BACKUP SCRIPT
On Proxmox, create the script:
Code:
nano /usr/local/bin/pve-backup.sh
Paste:
Code:
#!/bin/bash
# === CONFIGURATION ===
BACKUP_DIR="/root/pve-backups"
REMOTE_USER="backupuser"
REMOTE_HOST="192.168.1.100"
REMOTE_PATH="/backups/proxmox"
SSH_KEY="/root/.ssh/id_ed25519"
DATE=$(date +%F-%H%M)
ARCHIVE_NAME="pve-fullconfig-$DATE.tar.gz"
# === STEP 1: CREATE LOCAL BACKUP ===
mkdir -p "$BACKUP_DIR"
tar czf "$BACKUP_DIR/$ARCHIVE_NAME" \
/etc/pve \
/etc/network/interfaces \
/etc/fstab \
/etc/hosts \
/etc/hostname \
/etc/resolv.conf \
/etc/passwd \
/etc/shadow \
/etc/group \
/etc/pve/storage.cfg \
/etc/pve/datacenter.cfg \
/etc/pve/qemu-server \
/etc/pve/lxc \
/var/lib/lxc \
--warning=no-file-changed
echo "Backup created: $BACKUP_DIR/$ARCHIVE_NAME"
# === STEP 2: SYNC TO REMOTE ===
rsync -av --delete -e "ssh -i $SSH_KEY -o StrictHostKeyChecking=no" "$BACKUP_DIR/" "$REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH/"
echo "Remote sync complete."
# === STEP 3: CLEAN OLD LOCAL BACKUPS (>7 days) ===
find "$BACKUP_DIR" -type f -name "pve-fullconfig-*.tar.gz" -mtime +7 -exec rm -f {} \;
echo "Old local backups cleaned."
Make it executable:
Code:
chmod +x /usr/local/bin/pve-backup.sh
AUTOMATE IT
Edit root's crontab:
Code:
crontab -e
Add this line to run daily at 3:30 AM:
Code:
30 3 * * * /usr/local/bin/pve-backup.sh >> /var/log/pve-backup.log 2>&1
TEST EVERYTHING
Manually run:
Code:
/usr/local/bin/pve-backup.sh
Then check on remote:
Code:
ls -lh /backups/proxmox/
You should see your
.tar.gz archive with today’s date. No other junk. Clean and mirrored.Summary
Step | Description |
|---|---|
backupuser | Locked-down upload-only user with no shell |
SSH Key | Key-based auth from Proxmox only |
Secure | Only rsync is allowed remotely |
Prunes | Old backups deleted locally + mirrored remotely with --delete |
Fully automated daily job | |
Extensible | Easy to add more files or move to restic, borg, etc. later |
Need to back up actual VM disk snapshots (
vzdump) or integrate with offsite/cloud storage (S3, Backblaze, etc.) next?