Backup all Proxmox OpenVZ containers in one go

Backup all Proxmox OpenVZ containers in one go

Category : How-to

Get Social!

proxmox logo gradThe below script is a bash script which works with Proxmox and the OpenVZ commands to backup all known containers to a specified folder.

You will need to set BACKUP_PATH to be the folder where you would like the backups to be stored and COMPRESS to a value which specifies the compression used. COMPRESS values can be:

  • 0 – no compression.
  • 1 – default compression (usually lzo).
  • gzip – gzip compression.
  • lzo – lzo compression.

Paste the below file into /bin/backup_all and make sure it’s executable.

vi /bin/backup-all
# Filename : backup_all
# Description : Backup all OpenVZ containers in Proxmox
# Author : James Coyle
# Version:
# -Date      -Author     -Description
# 20-11-2013 James Coyle Initial


# Check dir exists
if [ ! -d $BACKUP_PATH ]; then
  echo "The directory $BACKUP_PATH does not exist."
  exit 99

VMARRAY=($(vzlist -a -H))

for V in ${VMARRAY[@]}
  VMIDS="$VMIDS ${V:7:3}"

if [ -n $VMIDS ]; then
  vzdump $VMIDS --dumpdir $BACKUP_PATH --mode snapshot --compress $COMPRESS --remove 0

echo "Backup of VMID(s) $VMIDS complete."

Leave a Reply

Visit our advertisers

Quick Poll

Are you using

Visit our advertisers