Skip to content

Commit

Permalink
Keep the cronjobs while installing a new version, fix #12 #10
Browse files Browse the repository at this point in the history
  • Loading branch information
franklupo committed Sep 18, 2017
1 parent 581fa4e commit 1ec0099
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.deb
*.deb
test/
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ DATE=$(shell LANG=en_us_8859_1; date '+%b %d, %Y')
DESTDIR=
PREFIX=/usr
SBINDIR=${PREFIX}/sbin
CRONDIR=/etc/cron.d
#CRONDIR=/etc/cron.d
MANDIR=${PREFIX}/share/man
DOCDIR=${PREFIX}/share/doc/${PACKAGE}
MAN8DIR=${MANDIR}/man8
Expand All @@ -23,8 +23,8 @@ install:
install -d ${DESTDIR}${SBINDIR}
install -m 0755 ${PACKAGE} ${DESTDIR}${SBINDIR}

install -d ${DESTDIR}${CRONDIR}
install -m 0644 ${PACKAGE}.cron ${DESTDIR}${CRONDIR}/${PACKAGE}
# install -d ${DESTDIR}${CRONDIR}
# install -m 0644 ${PACKAGE}.cron ${DESTDIR}${CRONDIR}/${PACKAGE}

install -d ${DESTDIR}${MAN8DIR}
install -m 0644 ${PACKAGE}.8 ${DESTDIR}${MAN8DIR}
Expand Down
8 changes: 8 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
eve4pve-barc (0.1.5)

* Keep the cronjobs while installing a new version of the package #9
* Check if snapshot exist in rbd pool in incremental #12
* Fix restore problem #10

-- EnterpriseVE Support Team <support@enterpriseve.com> 18 Sep 2017 15:42:01 +0100

eve4pve-barc (0.1.4)

* Add reset command remove all snapshots on images
Expand Down
39 changes: 23 additions & 16 deletions eve4pve-barc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# EnterpriseVE Backup And Restore Ceph for Proxmox VE.
# Author: Daniele Corsini <daniele.corsini@enterpriseve.com>

declare -r VERSION=0.1.4
declare -r VERSION=0.1.5
declare -r NAME=$(basename "$0")
declare -r PROGNAME=${NAME%.*}

Expand Down Expand Up @@ -85,7 +85,7 @@ Commands:
clean Clear all backup.
reset Remove all snapshots on images specific vm in Ceph.
backup Will backup one time.
restore Will restore one time.
restore Will restore image one time.
Options:
--vmid= The ID of the VM, comma separated (es. 100,101,102),
Expand Down Expand Up @@ -354,7 +354,6 @@ function remove_snaphot(){
[ "$hook" -eq 1 ] && call_hook_script "snap-remove-pre" "$snap" "-"
log info "VM $vm_id - Remove snapshot $snap"


#check is protectd
local info; info=$(rbd info $snap | grep 'protected: True');
if [ ! -z "$info" ]; then
Expand Down Expand Up @@ -442,7 +441,7 @@ function backup(){
#decode disk
local disk=''
for disk in $disks; do
#check rbd device image-spec is pool-name/image-name
#check rbd device image-spec is pool-name/image-name
local image_spec;

#if krbd enable
Expand Down Expand Up @@ -497,6 +496,13 @@ function backup(){
awk '{print $2}' | \
grep "$opt_label" | sort -r | head -n 1)

#not exist snapshot on rbd
if [ -z "$latest_snap" ]; then
log error "VM $vm_id - Ceph last snapshot '$image_spec' not found!";
call_hook_script "export-diff-abort" "-" "-"
break;
fi

#verify exist last snapshot ceph in file backup
#timestamp last snapshot
local tms_latest_snap
Expand Down Expand Up @@ -659,6 +665,8 @@ function reset(){
get_config_file
[ -z "$file_config" ] && continue

#disks available for vm/ct
#exclude no backup
local disks;
disks=$(cat "$file_config" | \
grep -P '^(?:((?:virtio|ide|scsi|sata|mp)\d+)|rootfs): ' | \
Expand All @@ -669,7 +677,7 @@ function reset(){
#decode disk
local disk=''
for disk in $disks; do
#check rbd device image-spec is pool-name/image-name
#check rbd device image-spec is pool-name/image-name
local image_spec;

#if krbd enable
Expand All @@ -696,12 +704,12 @@ function restore(){
for vm_id in $vm_ids; do
get_path

local title="EnterpriseVE Backup and Restore Ceph for Proxmox VE"
local title="EnterpriseVE BARC | Restore image"

#list all immge available
read -ra images <<<$(ls "$path_backup/"*$EXT_IMAGE | \
xargs -n 1 basename | \
awk '{printf "%s %s\n",substr($1,13,length($1)-16),substr($1,13,length($1)-16)}')
#list all image available
images=($(ls "$path_backup/"*$EXT_IMAGE | \
xargs -n 1 basename | \
awk '{printf "%s %s\n",substr($1,13,length($1)-16),substr($1,13,length($1)-16)}'))

#select image to recovery
local image;
Expand All @@ -712,10 +720,9 @@ function restore(){
[ -z "$image" ] && exit 1

#list all date available
read -ra timestamps <<<$(ls -r "$path_backup/"*$image* | \
xargs -n 1 basename | \
awk '{print substr($1,1,12),substr($1,1,12)}' | \
awk 'BEGIN {FIELDWIDTHS="13 2 2 2 2 2 2"} {printf "%s %s-%s-%s_%s:%s:%s\n",$1,$2,$3,$4,$5,$6,$7}')
timestamps=($(ls -r "$path_backup/"*$image* | \
xargs -n 1 basename | \
awk '{print substr($1,1,12),substr($1,1,2) "-" substr($1,3,2) "-" substr($1,5,2) "_" substr($1,7,2) ":" substr($1,9,2) ":" substr($1,11,2)}'))

#select timestamp
local timestamp
Expand All @@ -725,8 +732,8 @@ function restore(){

[ -z "$timestamp" ] && exit 1

#list all ppols
read -ra pools <<<$(rados lspools | awk '{printf "%s %s\n",$1,$1}')
#list all ppols
pools=($(rados lspools | awk '{printf "%s %s\n",$1,$1}'))

#select timestamp
local pool_name;
Expand Down

0 comments on commit 1ec0099

Please sign in to comment.