diff --git a/Makefile b/Makefile index be7acbf..1bd4892 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,6 @@ -VERSION=$(shell ./eve4pve-barc version) -DATE=$(shell LANG=en_us_8859_1; date '+%b %d, %Y') - PACKAGE=eve4pve-barc - +VERSION=$(shell ./${PACKAGE} version) +DATE=$(shell LANG=en_us_8859_1; date '+%b %d, %Y') DESTDIR= PREFIX=/usr SBINDIR=${PREFIX}/sbin @@ -30,7 +28,7 @@ install: install -d ${DESTDIR}${MAN8DIR} install -m 0644 ${PACKAGE}.8 ${DESTDIR}${MAN8DIR} - gzip ${DESTDIR}${MAN8DIR}/${PACKAGE}.8 + gzip -n -9 ${DESTDIR}${MAN8DIR}/${PACKAGE}.8 install -d ${DESTDIR}${EXAMPLE} install -m 0755 script-hook.sh ${DESTDIR}${EXAMPLE} @@ -41,7 +39,7 @@ deb ${DEB}: rm -rf debian mkdir debian - $(shell ./eve4pve-barc help --no-logo > help.tmp) + $(shell ./${PACKAGE} help --no-logo > help.tmp) sed '/@@COPYRIGHT@@/r copyright' ${PACKAGE}.8.template | \ sed "/@@COPYRIGHT@@/d" | \ sed '/@@SYNOPSIS@@/r help.tmp' | \ @@ -55,13 +53,14 @@ deb ${DEB}: install -d -m 0755 debian/DEBIAN sed -e s/@@VERSION@@/${VERSION}/ -e s/@@PACKAGE@@/${PACKAGE}/ debian/DEBIAN/control install -D -m 0644 copyright debian/${DOCDIR}/copyright - install -m 0644 changelog.Debian debian/${DOCDIR}/ - gzip -9 debian/${DOCDIR}/changelog.Debian + install -m 0644 changelog debian/${DOCDIR}/ + gzip -n -9 debian/${DOCDIR}/changelog dpkg-deb --build debian mv debian.deb ${DEB} rm -rf debian rm ${PACKAGE}.8 rm help.tmp + #lintian ${DEB} .PHONY: clean clean: diff --git a/README.md b/README.md index 232bea4..4dcf2d1 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,8 @@ Commands: Options: --vmid=string The ID of the VM, comma separated (es. 100,101,102), - 'all' for all known guest systems. + 'all-???' for all known guest systems in specific host (es. all-pve1, all-\$(hostname)), + 'all' for all known guest systems in cluster. --label=string Is usually 'hourly', 'daily', 'weekly', or 'monthly'. --path=string Path destination backup. --keep=integer Specify the number of backup which should will keep, Default 1. @@ -76,8 +77,10 @@ In backup export image and config file VM/CT. * Hook script * Multiple VM single execution * Copy config and firewall files -* Export any vm in cluster +* Export any vm in cluster 'all' +* Export any vm in specific host 'all-hostname' * Show size of backup and incremental +* Check 'No backup' flag in disk configuration # Configuration and use Download package eve4pve-barc_?.?.?-?_all.deb, on your Proxmox VE host and install: diff --git a/changelog.Debian b/changelog similarity index 79% rename from changelog.Debian rename to changelog index 5414527..82c0684 100644 --- a/changelog.Debian +++ b/changelog @@ -1,3 +1,10 @@ +eve4pve-barc (0.1.3) + + * Support krbd flag + * Add all-^??? hostname + + -- EnterpriseVE Support Team 13 Feb 2017 + eve4pve-barc (0.1.2) * Export any vm in cluster diff --git a/control.in b/control.in index 16228d2..ac458eb 100644 --- a/control.in +++ b/control.in @@ -1,5 +1,5 @@ Package: @@PACKAGE@@ -Section: Proxmox +Section: utils Version: @@VERSION@@ Priority: optional Architecture: all diff --git a/eve4pve-barc b/eve4pve-barc index cb24454..90cf37f 100755 --- a/eve4pve-barc +++ b/eve4pve-barc @@ -3,14 +3,17 @@ # EnterpriseVE Backup And Restore Ceph for Proxmox VE. # Author: Daniele Corsini -declare -r VERSION=0.1.2 +declare -r VERSION=0.1.3 declare -r NAME=$(basename "$0") declare -r PROGNAME=${NAME%.*} declare -r PVE_DIR="/etc/pve" declare -r PVE_FIREWALL="$PVE_DIR/firewall" -declare -r QEMU_CONF="$PVE_DIR/nodes/*/qemu-server" -declare -r LXC_CONF="$PVE_DIR/nodes/*/lxc" +declare -r PVE_NODES="$PVE_DIR/nodes" +declare -r QEMU='qemu-server' +declare -r LXC='lxc' +declare -r QEMU_CONF_CLUSTER="$PVE_NODES/*/$QEMU" +declare -r LXC_CONF_CLUSTER="$PVE_NODES/*/$LXC" declare -r EXT_IMAGE='.img' declare -r EXT_DIFF='.diff' @@ -82,7 +85,8 @@ Commands: Options: --vmid=string The ID of the VM, comma separated (es. 100,101,102), - 'all' for all known guest systems. + 'all-???' for all known guest systems in specific host (es. all-pve1, all-\$(hostname)), + 'all' for all known guest systems in cluster. --label=string Is usually 'hourly', 'daily', 'weekly', or 'monthly'. --path=string Path destination backup. --keep=integer Specify the number of backup which should will keep, Default 1. @@ -121,6 +125,32 @@ function log(){ esac } +function get_vm_ids(){ + local data='' + local conf='' + + while [ $# -gt 0 ]; do + for conf in $1; do + [ ! -e "$conf" ] && break + + conf=$(basename "$conf") + [ "$data" != '' ] && data="$data," + data="$data${conf%.*}" + done + shift + done + + echo "$data" +} + +function exist_file(){ + local file='' + for file in $1; do + [ -e "$file" ] && return 0 || return 1 + break + done +} + function parse_opts(){ local action=$1 shift @@ -154,28 +184,28 @@ function parse_opts(){ [ ! -d "$opt_path_backup" ] && { log info "Path Backup is not set"; exit 1; } [ -z "$opt_vm_ids" ] && { log info "VM id is not set."; exit 1; } if [ "$opt_vm_ids" = "all" ]; then - vm_ids='' - local conf='' + #all in cluster - #VM - for conf in $QEMU_CONF/*$EXT_CONF; do - [ ! -e "$conf" ] && break + local data='' + data=$(get_vm_ids "$QEMU_CONF_CLUSTER/*$EXT_CONF" "$LXC_CONF_CLUSTER/*$EXT_CONF") + vm_ids=$(echo "$data" | tr ',' '\n') - conf=$(basename "$conf") - [ "$vm_ids" != '' ] && vm_ids="$vm_ids," - vm_ids="$vm_ids${conf%.*}" - done + elif [[ "$opt_vm_ids" == "all-"* ]]; then + #all in specific host - #CT - for conf in $LXC_CONF/*$EXT_CONF; do - [ ! -e "$conf" ] && break + local host=${opt_vm_ids#*-} + + if ! exist_file "$PVE_NODES/$host"; then + log info "Host not found!" + exit 1 + fi - conf=$(basename "$conf") - [ "$vm_ids" != '' ] && vm_ids="$vm_ids," - vm_ids="$vm_ids${conf%.*}" - done + local data='' + data=$(get_vm_ids "$PVE_NODES/$host/$QEMU/*$EXT_CONF" "$PVE_NODES/$host/$LXC/*$EXT_CONF") + [ -z "$data" ] && { log info "VM id is not set."; exit 1; } + + vm_ids=$(echo "$data" | tr ',' '\n') - vm_ids=$(echo "$vm_ids" | tr ',' '\n') else #comma separated vm_ids=$(echo "$opt_vm_ids" | tr ',' '\n') @@ -355,14 +385,6 @@ function call_hook_script(){ fi } -function exist_file(){ - local file='' - for file in $1; do - [ -e "$file" ] && return 0 || return 1 - break - done -} - function backup(){ parse_opts "$@" @@ -389,15 +411,15 @@ function backup(){ local file_config='' #check tecnology - if exist_file "$QEMU_CONF/$vm_id$EXT_CONF"; then - file_config=$(ls $QEMU_CONF/$vm_id$EXT_CONF) + if exist_file "$QEMU_CONF_CLUSTER/$vm_id$EXT_CONF"; then + file_config=$(ls $QEMU_CONF_CLUSTER/$vm_id$EXT_CONF) if ! grep -q 'agent: 1' < "$file_config"; then log info "VM $vm_id consider enabling QEMU agent see https://pve.proxmox.com/wiki/Qemu-guest-agent" fi - elif exist_file "$LXC_CONF/$vm_id$EXT_CONF"; then - file_config=$(ls $LXC_CONF/$vm_id$EXT_CONF) + elif exist_file "$LXC_CONF_CLUSTER/$vm_id$EXT_CONF"; then + file_config=$(ls $LXC_CONF_CLUSTER/$vm_id$EXT_CONF) else log error "VM $vm_id - Unknown tecnology" @@ -423,8 +445,13 @@ function backup(){ for disk in $disks; do #check rbd device image-spec is pool-name/image-name local image_spec; - image_spec=$(pvesm path "$disk" | grep 'ceph' | awk '{ split($0,a,":"); print a[2]}') - [ -z "$image_spec" ] && continue + + #if krbd enable + image_spec=$(pvesm path "$disk" | grep '^/dev/rbd/' | sed -e "s/^\/dev\/rbd\///") + if [ -z "$image_spec" ]; then + image_spec=$(pvesm path "$disk" | grep '/ceph/' | awk '{ split($0,a,":"); print a[2]}') + [ -z "$image_spec" ] && continue + fi #pool-name/image-name@snap-name local current_snap="$image_spec@$snap_name_prefix$timestamp"