How to backup PVE itself ?

Fathi

Renowned Member
May 13, 2016
133
4
83
52
Tunis, Tunisia
Hello,
It's great to have PBS to solve the container/vm backup need, but how to backup PVE itself or which files needs to be backed up for a bare metal restoration ?
TIA.
 
Hi, is there a straight forward procedure to backup the PVE itslelf like for vms or containers ? Not everyone (including me) knows which files/folders of a pve to backup. What about clusters ? Does backing up each pve node alone may lead to inconsistencies when restoring ? Should all nodes be backed up at the "same time" ? In which order to restore ? I have a small cluster of three nodes, what about bigger clusters ?
TIA
Fathi Ben Nas
 
Hello, is there in 2023 something new about PBS on this?

Backuping VM/Containers is quite straightforward. But i´m having quite a hard time with backuping PVE with PBS.

Why i want to backup PVE:
  • I can make update / configuration which will cause VM/containers to stop working and by restoring backup it will work again in minutes as it was.
  • Hardware problem with disks -> new disks -> simple restore of 1) ProxmoxVE and 2) VM/containers

Is my way of thinking bad practice? Should i proceed differently in case of PVE damage?

Many thanks :)
 
There is no easy way to backup your host yet. But you could use the proxmox-backup-client while PVE is running to backup the PVE config files to your PBS. Or you could boot into a Debian (so PVE isn't running) with proxmox-backup-client installed and use that to backup your system disks on block level to your PBS.
 
Last edited:
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:
  1. Creates new user with token and "DatastoreBackup" access role
  2. Creates cron which run at _HOUR
    1. Wrote installed packages and pve report to root home directory
    2. 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
 
Firstly Many Many Thanks for this, couple of questions

Im presuming this bash script need to be saved in /root (after I read this asking after is saw this chmod +x /root/backup_pve.sh /etc/cron.d/backup_pve )
im presuming that the bash file stops at ... echo "0 ${_HOUR} * * * root /root/backup_pve.sh" > /etc/cron.d/backup_pve <<<<here

many thanks again, mega nube over and out.

DC



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:
  1. Creates new user with token and "DatastoreBackup" access role
  2. Creates cron which run at _HOUR
    1. Wrote installed packages and pve report to root home directory
    2. 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
 
Firstly Many Many Thanks for this, couple of questions

Im presuming this bash script need to be saved in /root (after I read this asking after is saw this chmod +x /root/backup_pve.sh /etc/cron.d/backup_pve )
im presuming that the bash file stops at ... echo "0 ${_HOUR} * * * root /root/backup_pve.sh" > /etc/cron.d/backup_pve <<<<here

many thanks again, mega nube over and out.

DC
OK OK.. after much reading I have deduced that this script runs on the PBS backup instance and backs itself up to its own datastore..

Was hoping for a backup solution to backup the host to a pbs instance..

will keep searching
Many Thanks

DC
 
  • Like
Reactions: Roopee
What you should backup is the config in /etc, proxmox specific settings are in /etc/pve

I suggest installing etckeeper to track changes locally
 
one way to find out for sure.. test it

will report back as soon as ive done it
I'd love to know - did you ever test this, and if so what did you find? I have exactly the same basic problem in that I want to backup my PVE instances to PBS instances, but since I don't have shared storage (Ceph etc) obviously not to PBS running on the PVE it is backing up!

I'm also wondering (in case any Proxmox people are reading!) why, if it's so relatively trivial that it can be achieved by running such a short script (but certainly not one that I could write), it isn't already built in to the GUI, since backing up PVE itself must surely be high on the list of any Proxmox user's to-do list?

I'm not complaining or asking for a refund - I'm already getting a wonderful product for free - it just seems like an oversight, unless I'm missing something?
 
It works:

#!/bin/sh
export PBS_PASSWORD=MYPASS
export PBS_REPOSITORY=root@pam@MYIP:tank9
proxmox-backup-client backup pve2-etc.pxar:/etc --include-dev /etc/pve >/dev/null 2>&1
export PBS_PASSWORD=
export PBS_REPOSITORY=

i added this script file "pve-backup" in /etc/cron.daily

works great

why its not built in not sure.... probably will be one day. dont forget the --include-dev LOL
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!