There is about all you need documented here:
https://pbs.proxmox.com/docs/backup-client.html
https://pbs.proxmox.com/docs/user-management.html
And what needs to be/is recommended to backed up is discussed in many threads.
With little reading and Linux/Bash knowhow I wrote this:
Bash:
_USERNAME="svc-backup-api"
_DATASTORE="backup"
_TOKEN="pve"
_HOUR="5"
proxmox-backup-manager user \
create "${_USERNAME}@pbs"
cat <<EOF >/root/backup_pve.sh
#!/bin/bash
export PBS_PASSWORD="$(
proxmox-backup-manager user \
generate-token "${_USERNAME}@pbs" "${_TOKEN}" \
| grep -o '"value": "[^"]*' \
| grep -o '[^"]*$'
)"
export PBS_FINGERPRINT="$(
proxmox-backup-manager cert \
info \
| grep Fingerprint \
| cut -d" " -f3
)"
apt-mark showmanual > /root/packages.list
pvereport > /root/report.txt
proxmox-backup-client backup \\
etc.pxar:/etc \\
root.pxar:/root \\
cluster.pxar:/var/lib/pve-cluster \\
cron.pxar:/var/spool/cron \\
--include-dev /etc/pve \\
--repository "${_USERNAME}@pbs"'!'"${_TOKEN}@localhost:8007:${_DATASTORE}"
unset PBS_PASSWORD
exit 0
EOF
proxmox-backup-manager acl \
update "/datastore/${_DATASTORE}" DatastoreBackup \
--auth-id "${_USERNAME}@pbs"
proxmox-backup-manager acl \
update "/datastore/${_DATASTORE}" DatastoreBackup \
--auth-id "${_USERNAME}@pbs"'!'"${_TOKEN}"
echo "0 ${_HOUR} * * * root /root/backup_pve.sh" > /etc/cron.d/backup_pve
chmod +x /root/backup_pve.sh /etc/cron.d/backup_pve
Basically:
- Creates new user with token and "DatastoreBackup" access role
- Creates cron which run at _HOUR
- Wrote installed packages and pve report to root home directory
- Backup /etc, /root, /var/lib/pve-cluster, /var/spool/cron directories to _DATASTORE
If you do not have PBS on the same host as PVE then run commands separately on PBS and change hostname (localhost) to your PBS server IP/name