Backup of pve config files

taich

Active Member
Aug 15, 2020
117
20
38
65
Since I could not find a way to backup most important pve config files, I made this little script.
It creates a tar file of most important config files and sends the file to an email address.
May be someone can use.

Bash:
#!/bin/bash
#
apt install mutt
#
RECIPIENT=user@example.com
THISHOST=$(hostname -f)
TARFILE=${THISHOST}.tar

if [ -f /etc/network/interfaces ]; then
   tar -cf ${TARFILE} /etc/network/interfaces
fi
if [ -f /etc/sysctl.conf ]; then
   tar -rf ${TARFILE} /etc/sysctl.conf
fi
if [ -f /etc/vzdump.conf ]; then
   tar -rf ${TARFILE} /etc/vzdump.conf
fi
if [ -f /etc/fstab ]; then
   tar -rf ${TARFILE} /etc/fstab
fi
if [ -f /etc/pve/vzdump.cron ]; then
   tar -rf ${TARFILE} /etc/pve/vzdump.cron
fi
if [ -f /etc/pve/user.cfg ]; then
   tar -rf ${TARFILE} /etc/pve/user.cfg
fi
if [ -f /etc/pve/storage.cfg ]; then
   tar -rf ${TARFILE} /etc/pve/storage.cfg
fi
if [ -f /etc/pve/firewall/cluster.fw ]; then
   tar -rf ${TARFILE} /etc/pve/firewall/cluster.fw
fi

echo "tar backup from ${THISHOST}" | mutt -s "${TARFILE}" "${RECIPIENT}" -a ${TARFILE}
rm ${TARFILE}
 
And in case you got a PBS running you can also use the proxmox-backup-client to backup those files to your PBS instead of manually tarring and sending them per mail. PBS stores them deduplicated and nothing needs to be stored twice, so I just backup the whole /etc folder every week to my PBS.
 
Last edited:
Sad to see configuration backups are STILL not included in the gui. This just made my day 10times more harder. Can reconfigure a complete cluster because of this bullshit. Wish i had the script beforehand.