Created
November 25, 2013 08:32
-
-
Save k0nsl/7638196 to your computer and use it in GitHub Desktop.
Backup all OpenVZ containers in Proxmox. Author James Coyle.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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