Skip to content

Commit

Permalink
Merge pull request #278 from Arakmar/backupIso
Browse files Browse the repository at this point in the history
Backup in ISO feature
  • Loading branch information
gdha committed Jul 12, 2013
2 parents 4df751c + 7c8cb79 commit 0728f12
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 11 deletions.
6 changes: 3 additions & 3 deletions usr/share/rear/backup/NETFS/GNU/Linux/60_start_selinux.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Start SELinux if it was stopped - check presence of /tmp/selinux.mode
[ -f $TMP_DIR/selinux.mode ] && {
local scheme=$(url_scheme $OUTPUT_URL)
local path=$(url_path $OUTPUT_URL)
local opath=$(output_path $scheme $path)
local scheme=$(url_scheme $BACKUP_URL)
local path=$(url_path $BACKUP_URL)
local opath=$(backup_path $scheme $path)
cat $TMP_DIR/selinux.mode > $SELINUX_ENFORCE
Log "Restored original SELinux mode"
touch "${opath}/selinux.autorelabel"
Expand Down
6 changes: 3 additions & 3 deletions usr/share/rear/backup/RSYNC/GNU/Linux/62_force_autorelabel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
;;

(*)
local scheme=$(url_scheme $OUTPUT_URL)
local path=$(url_path $OUTPUT_URL)
local opath=$(output_path $scheme $path)
local scheme=$(url_scheme $BACKUP_URL)
local path=$(url_path $BACKUP_URL)
local opath=$(backup_path $scheme $path)
# probably using the BACKUP=NETFS workflow instead
if [ -d "${opath}" ]; then
if [ ! -f "${opath}/selinux.autorelabel" ]; then
Expand Down
23 changes: 22 additions & 1 deletion usr/share/rear/lib/global-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ backup_path() {
(file) # type file needs a local path (must be mounted by user)
path="$path/${NETFS_PREFIX}"
;;
(iso)
if [[ "$WORKFLOW" = "recover" ]]; then
# The backup is located inside the ISO mount point when we do a recover
path="${BUILD_DIR}/outputfs${path}"
else
# The backup will be located on the ISO temporary dir
path="${TMP_DIR}/isofs${path}"
fi
;;
(*) # nfs, cifs, usb, a.o. need a temporary mount-path
path="${BUILD_DIR}/outputfs/${NETFS_PREFIX}"
;;
Expand Down Expand Up @@ -97,6 +106,13 @@ mount_url() {
### Don't need to mount anything for these
return 0
;;
(iso)
if [[ "$WORKFLOW" = "recover" ]]; then
mount_cmd="mount -o loop /dev/disk/by-label/${ISO_VOLID} $mountpoint"
else
return 0
fi
;;
(var)
### The mount command is given by variable in the url host
local var=$(url_host $url)
Expand All @@ -114,7 +130,7 @@ mount_url() {
;;
(sshfs)
mount_cmd="sshfs $(url_host $url):$(url_path $url) $mountpoint -o $options"
;;
;;
(*)
mount_cmd="mount $v -t $(url_scheme $url) -o $options $(url_host $url):$(url_path $url) $mountpoint"
;;
Expand All @@ -138,6 +154,11 @@ umount_url() {
### Don't need to umount anything for these
return 0
;;
(iso)
if [[ "$WORKFLOW" != "recover" ]]; then
return 0
fi
;;
(sshfs)
umount_cmd="fusermount -u $mountpoint"
;;
Expand Down
7 changes: 7 additions & 0 deletions usr/share/rear/lib/mkbackup-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
WORKFLOW_mkbackup_DESCRIPTION="create rescue media and backup system"
WORKFLOWS=( ${WORKFLOWS[@]} mkbackup )
WORKFLOW_mkbackup () {
local scheme=$(url_scheme $BACKUP_URL)
for arg in "${ARGS[@]}" ; do
key=OPT_"${arg%%=*}"
val="${arg#*=}"
Expand All @@ -20,8 +21,14 @@ WORKFLOW_mkbackup () {
SourceStage "build"

SourceStage "pack"
if [[ "$scheme" = "iso" ]] && [[ "$OUTPUT" = "ISO" ]]; then
# In this case, we need to give backups a chance to be integrated in the iso before the copy to OUTPUT_URL
SourceStage "backup"

SourceStage "output"
else
SourceStage "output"

SourceStage "backup"
fi
}
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 @@ -3,7 +3,7 @@

local scheme=$(url_scheme $BACKUP_URL)
case "$TAPE_DEVICE:$scheme" in
(:file)
(:file|:iso)
# define the output path according to the scheme
local path=$(url_path $BACKUP_URL)
local opath=$(backup_path $scheme $path)
Expand Down
3 changes: 3 additions & 0 deletions usr/share/rear/prep/default/04_check_output_scheme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ if [[ "$OUTPUT_URL" ]] ; then
if [[ -z "$(type -p lftp)" ]]; then
Error "The OUTPUT_URL scheme $output_scheme requires the 'lftp' command, which is missing!"
fi ;;
(iso)
Error "The OUTPUT_URL scheme can't be $output_scheme. You must choose a correct location !"
;;
esac
fi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# If selinux was turned off for the backup we have to label the
local scheme=$(url_scheme $OUTPUT_URL)
local path=$(url_path $OUTPUT_URL)
local opath=$(output_path $scheme $path)
local scheme=$(url_scheme $BACKUP_URL)
local path=$(url_path $BACKUP_URL)
local opath=$(backup_path $scheme $path)

[ -f "${opath}/selinux.autorelabel" ] && { \
touch /mnt/local/.autorelabel
Expand Down

0 comments on commit 0728f12

Please sign in to comment.