diff --git a/README.md b/README.md index 3a60192..52b6efd 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Usage: ./vzpbackup.sh [--suspend=] [--backup-dir=] [--work-dir=] + [--filename=] [--compress=] [--compact] [--all] @@ -48,6 +49,10 @@ Options: Parameter to change the default working directory. Either use the parameter or change the script. +--filename=\ (Default: vzpbackup+_hostname_+CTID+_containerhostname_+timestamp) + + Parameter to change the default backup filename + --compact Runs vzctl compact for each container before initiating diff --git a/vzpbackup.sh b/vzpbackup.sh index 744f721..fcabc5c 100755 --- a/vzpbackup.sh +++ b/vzpbackup.sh @@ -27,6 +27,7 @@ BACKUP_DIR=/store/vzpbackup WORK_DIR=/store/vzpbackup COMPRESS=no COMPACT=0 +FILENAME ## ## VARIABLES @@ -67,6 +68,7 @@ Usage: $0 \t[--suspend=] \t[--backup-dir=] \t[--work-dir=] +\t[--filename=] \t[--compress=] \t[--compact] \t[--all] @@ -81,6 +83,7 @@ show_param() { echo -e "SUSPEND: \t\t$SUSPEND" echo -e "BACKUP_DIR: \t\t$BACKUP_DIR" echo -e "WORK_DIR: \t\t$WORK_DIR" + echo -e "FILENAME: \t\t$FILENAME" echo -e "COMPRESS: \t\t$COMPRESS" echo -e "COMPACT: \t\t$COMPACT" echo -e "CTIDs to backup: \t\t$CTIDS" @@ -118,6 +121,9 @@ case $i in --work-dir=*) WORK_DIR=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` ;; + --filename=*) + FILENAME=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` + ;; --compress=*) COMPRESS=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` ;; @@ -191,7 +197,11 @@ if grep -w "$CTID" <<< `$VZLIST_CMD -a -Hoctid` &> /dev/null; then # a possible the dump (while being suspended) and container config cd $VE_PRIVATE HNAME=`$VZLIST_CMD -Hohostname $CTID` + + if [ -z "$FILENAME" ]; then FILENAME="${PREFIX}${CTID}_${HNAME}_${TIMESTAMP}" + fi + COMPRESS_SUFFIX="" if [ "$COMPRESS" == "tgz" ]; then