Skip to content

Commit

Permalink
merged patch from pavoldomin (issue #192) concerning better BACKUP/OU…
Browse files Browse the repository at this point in the history
…TPUT_URL split-up

=> must say would have been easier if it was a pull request.
=> in my tests it seems to work, but need plenty more user-tests and feedback
==> keep this issue open for follow-up matters
@pavoldomin thanks for the patch - can you test it as well?
Gratien
  • Loading branch information
gdha committed Feb 5, 2013
1 parent aa493f5 commit a8fdc44
Show file tree
Hide file tree
Showing 17 changed files with 97 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
url="$( echo $stage | tr '[:lower:]' '[:upper:]')_URL"
local scheme=$(url_scheme ${!url})
local path=$(url_path ${!url})
local opath=$(output_path $scheme $path)
local opath=$(backup_path $scheme $path)

# if $opath is empty return silently (e.g. scheme tape)
[ -z "$opath" ] && return 0
Expand Down
2 changes: 1 addition & 1 deletion usr/share/rear/backup/NETFS/default/20_make_prefix_dir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
url="$( echo $stage | tr '[:lower:]' '[:upper:]')_URL"
local scheme=$(url_scheme ${!url})
local path=$(url_path ${!url})
local opath=$(output_path $scheme $path)
local opath=$(backup_path $scheme $path)

# if $opath is empty return silently (e.g. scheme tape)
[ -z "$opath" ] && return 0
Expand Down
2 changes: 1 addition & 1 deletion usr/share/rear/backup/NETFS/default/25_create_lock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
url="$( echo $stage | tr '[:lower:]' '[:upper:]')_URL"
local scheme=$(url_scheme ${!url})
local path=$(url_path ${!url})
local opath=$(output_path $scheme $path)
local opath=$(backup_path $scheme $path)

# if $opath is empty return silently (e.g. scheme tape)
[ -z "$opath" ] && return 0
Expand Down
2 changes: 1 addition & 1 deletion usr/share/rear/backup/NETFS/default/50_make_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ done < $TMP_DIR/backup-exclude.txt

local scheme=$(url_scheme $BACKUP_URL)
local path=$(url_path $BACKUP_URL)
local opath=$(output_path $scheme $path)
local opath=$(backup_path $scheme $path)

if [[ "$opath" ]]; then
mkdir -p $v "${opath}" >&2
Expand Down
7 changes: 4 additions & 3 deletions usr/share/rear/backup/NETFS/default/97_remove_lock.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# remove the lockfile
local scheme=$(url_scheme $OUTPUT_URL)
local path=$(url_path $OUTPUT_URL)
local opath=$(output_path $scheme $path)
url="$( echo $stage | tr '[:lower:]' '[:upper:]')_URL"
local scheme=$(url_scheme ${!url})
local path=$(url_path ${!url})
local opath=$(backup_path $scheme $path)

# if $opath is empty return silently (e.g. scheme tape)
[ -z "$opath" ] && return 0
Expand Down
4 changes: 4 additions & 0 deletions usr/share/rear/conf/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ OUTPUT_URL=
OUTPUT_OPTIONS=
OUTPUT_MOUNTCMD=
OUTPUT_UMOUNTCMD=
OUTPUT_PREFIX="$HOSTNAME"
# keep an older copy of the output (mv $OUTPUT_PREFIX $OUTPUT_PREFIX.old before we copy the new version)
# empty means only keep current output
KEEP_OLD_OUTPUT_COPY=

##
# OUTPUT=RAMDISK stuff
Expand Down
20 changes: 19 additions & 1 deletion usr/share/rear/lib/global-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ url_path() {
echo /${path#*/}
}

output_path() {
backup_path() {
local scheme=$1
local path=$2
case $scheme in
Expand All @@ -65,6 +65,24 @@ output_path() {
echo "$path"
}

output_path() {
local scheme=$1
local path=$2
case $scheme in
(tape) # no path for tape required
path=""
;;
(file) # type file needs a local path (must be mounted by user)
path="$path/${OUTPUT_PREFIX}"
;;
(*) # nfs, cifs, usb, a.o. need a temporary mount-path
path="${BUILD_DIR}/outputfs/${OUTPUT_PREFIX}"
;;
esac
echo "$path"
}


### Mount URL $1 at mountpoint $2[, with options $3]
mount_url() {
local url=$1
Expand Down
38 changes: 0 additions & 38 deletions usr/share/rear/output/ISO/Linux-i386/90_transfer_image.sh

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion usr/share/rear/output/NETFS/default/20_make_prefix_dir.sh

This file was deleted.

1 change: 0 additions & 1 deletion usr/share/rear/output/NETFS/default/25_create_lock.sh

This file was deleted.

25 changes: 25 additions & 0 deletions usr/share/rear/output/default/15_save_copy_of_prefix_dir.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# if KEEP_OLD_OUTPUT_COPY is not empty then move old OUTPUT_PREFIX directory to OUTPUT_PREFIX.old

[ -z "${KEEP_OLD_OUTPUT_COPY}" ] && return

# do not do this for tapes and special attention for file:///path
url="$( echo $stage | tr '[:lower:]' '[:upper:]')_URL"
local scheme=$(url_scheme ${!url})
local path=$(url_path ${!url})
local opath=$(output_path $scheme $path)

# if $opath is empty return silently (e.g. scheme tape)
[ -z "$opath" ] && return 0

if ! test -f "${opath}/.lockfile" ; then
# lockfile made through workflow backup already (so output keep hands off)
if test -d "${opath}" ; then
rm -rf $v "${opath}.old" >&2
StopIfError "Could not remove '${opath}.old'"
mv -f $v "${opath}" "${opath}.old" >&2
StopIfError "Could not move '${opath}'"
fi
else
Log "Lockfile '${opath}/.lockfile' found. Not keeping old backup data."
fi
# the ${BUILD_DIR}/outputfs/${OUTPUT_PREFIX} will be created by output/default/20_make_prefix_dir.sh
14 changes: 14 additions & 0 deletions usr/share/rear/output/default/20_make_prefix_dir.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# if set, create $OUTPUT_PREFIX under the mounted network filesystem share. This defaults
# to $HOSTNAME

# do not do this for tapes and special attention for file:///path
url="$( echo $stage | tr '[:lower:]' '[:upper:]')_URL"
local scheme=$(url_scheme ${!url})
local path=$(url_path ${!url})
local opath=$(output_path $scheme $path)

# if $opath is empty return silently (e.g. scheme tape)
[ -z "$opath" ] && return 0

mkdir -p $v -m0750 "${opath}" >&2
StopIfError "Could not mkdir '${opath}'"
16 changes: 16 additions & 0 deletions usr/share/rear/output/default/25_create_lock.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# create a lockfile in $OUTPUT_PREFIX to avoid that mkrescue overwrites ISO/PXE/LOGFILE
# made by a previous mkrescue run when the variable KEEP_OLD_OUTPUT_COPY has been set

# do not do this for tapes and special attention for file:///path
url="$( echo $stage | tr '[:lower:]' '[:upper:]')_URL"
local scheme=$(url_scheme ${!url})
local path=$(url_path ${!url})
local opath=$(output_path $scheme $path)

# if $opath is empty return silently (e.g. scheme tape)
[ -z "$opath" ] && return 0

if test -d "${opath}" ; then
> "${opath}/.lockfile"
StopIfError "Could not create '${opath}/.lockfile'"
fi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# copy resulting files to network backup location
# copy resulting files to network output location

local scheme=$(url_scheme $OUTPUT_URL)
local path=$(url_path $OUTPUT_URL)
Expand Down
9 changes: 9 additions & 0 deletions usr/share/rear/output/default/97_remove_lock.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# remove the lockfile
local scheme=$(url_scheme $OUTPUT_URL)
local path=$(url_path $OUTPUT_URL)
local opath=$(output_path $scheme $path)

# if $opath is empty return silently (e.g. scheme tape)
[ -z "$opath" ] && return 0

rm -f $v "${opath}/.lockfile" >&2
2 changes: 1 addition & 1 deletion usr/share/rear/prep/NETFS/default/07_set_backup_archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ case "$TAPE_DEVICE:$scheme" in
(:file)
# define the output path according to the scheme
local path=$(url_path $BACKUP_URL)
local opath=$(output_path $scheme $path)
local opath=$(backup_path $scheme $path)
backuparchive="${opath}/${BACKUP_PROG_ARCHIVE}${BACKUP_PROG_SUFFIX}${BACKUP_PROG_COMPRESS_SUFFIX}"
;;
(:*)
Expand Down

0 comments on commit a8fdc44

Please sign in to comment.