Skip to content

Instantly share code, notes, and snippets.

@k0nsl
Created November 25, 2013 08:32
Show Gist options
  • Select an option

  • Save k0nsl/7638196 to your computer and use it in GitHub Desktop.

Select an option

Save k0nsl/7638196 to your computer and use it in GitHub Desktop.
Backup all OpenVZ containers in Proxmox. Author James Coyle.
#!/bin/bash
#
# Filename : backup_all
# Description : Backup all OpenVZ containers in Proxmox
# Author : James Coyle
#
# Version:
# -Date -Author -Description
# 20-11-2013 James Coyle Initial
#
#
BACKUP_PATH=/var/lib/vz/dump
COMPRESS="lzo"
# Check dir exists
if [ ! -d $BACKUP_PATH ]; then
echo "The directory $BACKUP_PATH does not exist."
exit 99
fi
IFS=$'\n'
VMARRAY=($(vzlist -a -H))
VMIDS=""
for V in ${VMARRAY[@]}
do
VMIDS="$VMIDS ${V:7:3}"
done
if [ -n $VMIDS ]; then
vzdump $VMIDS --dumpdir $BACKUP_PATH --mode snapshot --compress $COMPRESS --remove 0
fi
echo "Backup of VMID(s) $VMIDS complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment