From 1db133f0a74bf3094f5196fe874543c50d3bed5a Mon Sep 17 00:00:00 2001 From: gozora Date: Tue, 6 Dec 2016 17:48:46 +0100 Subject: [PATCH] Initial support for block device cloning --- .../default/100_mount_NETFS_path.sh | 1 + .../default/150_save_copy_of_prefix_dir.sh | 1 + .../BLOCKCLONE/default/200_make_prefix_dir.sh | 1 + .../BLOCKCLONE/default/250_create_lock.sh | 1 + .../BLOCKCLONE/default/500_start_clone.sh | 27 +++++++++++++++++++ .../BLOCKCLONE/default/970_remove_lock.sh | 1 + .../default/980_umount_NETFS_dir.sh | 1 + usr/share/rear/conf/default.conf | 25 +++++++---------- .../default/050_check_NETFS_requirements.sh | 1 + .../default/060_mount_NETFS_path.sh | 1 + .../default/070_set_backup_archive.sh | 1 + .../default/100_check_nfs_version.sh | 1 + .../default/980_umount_NETFS_dir.sh | 1 + 13 files changed, 48 insertions(+), 15 deletions(-) create mode 120000 usr/share/rear/backup/BLOCKCLONE/default/100_mount_NETFS_path.sh create mode 120000 usr/share/rear/backup/BLOCKCLONE/default/150_save_copy_of_prefix_dir.sh create mode 120000 usr/share/rear/backup/BLOCKCLONE/default/200_make_prefix_dir.sh create mode 120000 usr/share/rear/backup/BLOCKCLONE/default/250_create_lock.sh create mode 100644 usr/share/rear/backup/BLOCKCLONE/default/500_start_clone.sh create mode 120000 usr/share/rear/backup/BLOCKCLONE/default/970_remove_lock.sh create mode 120000 usr/share/rear/backup/BLOCKCLONE/default/980_umount_NETFS_dir.sh create mode 120000 usr/share/rear/prep/BLOCKCLONE/default/050_check_NETFS_requirements.sh create mode 120000 usr/share/rear/prep/BLOCKCLONE/default/060_mount_NETFS_path.sh create mode 120000 usr/share/rear/prep/BLOCKCLONE/default/070_set_backup_archive.sh create mode 120000 usr/share/rear/prep/BLOCKCLONE/default/100_check_nfs_version.sh create mode 120000 usr/share/rear/prep/BLOCKCLONE/default/980_umount_NETFS_dir.sh diff --git a/usr/share/rear/backup/BLOCKCLONE/default/100_mount_NETFS_path.sh b/usr/share/rear/backup/BLOCKCLONE/default/100_mount_NETFS_path.sh new file mode 120000 index 0000000000..60e0f83fce --- /dev/null +++ b/usr/share/rear/backup/BLOCKCLONE/default/100_mount_NETFS_path.sh @@ -0,0 +1 @@ +../../NETFS/default/100_mount_NETFS_path.sh \ No newline at end of file diff --git a/usr/share/rear/backup/BLOCKCLONE/default/150_save_copy_of_prefix_dir.sh b/usr/share/rear/backup/BLOCKCLONE/default/150_save_copy_of_prefix_dir.sh new file mode 120000 index 0000000000..2238c2ded2 --- /dev/null +++ b/usr/share/rear/backup/BLOCKCLONE/default/150_save_copy_of_prefix_dir.sh @@ -0,0 +1 @@ +../../NETFS/default/150_save_copy_of_prefix_dir.sh \ No newline at end of file diff --git a/usr/share/rear/backup/BLOCKCLONE/default/200_make_prefix_dir.sh b/usr/share/rear/backup/BLOCKCLONE/default/200_make_prefix_dir.sh new file mode 120000 index 0000000000..100019fbd5 --- /dev/null +++ b/usr/share/rear/backup/BLOCKCLONE/default/200_make_prefix_dir.sh @@ -0,0 +1 @@ +../../NETFS/default/200_make_prefix_dir.sh \ No newline at end of file diff --git a/usr/share/rear/backup/BLOCKCLONE/default/250_create_lock.sh b/usr/share/rear/backup/BLOCKCLONE/default/250_create_lock.sh new file mode 120000 index 0000000000..58faa3921e --- /dev/null +++ b/usr/share/rear/backup/BLOCKCLONE/default/250_create_lock.sh @@ -0,0 +1 @@ +../../NETFS/default/250_create_lock.sh \ No newline at end of file diff --git a/usr/share/rear/backup/BLOCKCLONE/default/500_start_clone.sh b/usr/share/rear/backup/BLOCKCLONE/default/500_start_clone.sh new file mode 100644 index 0000000000..6c99e68b99 --- /dev/null +++ b/usr/share/rear/backup/BLOCKCLONE/default/500_start_clone.sh @@ -0,0 +1,27 @@ +# This file is part of Relax-and-Recover, licensed under the GNU General +# Public License. Refer to the included COPYING for full text of license. +# +# 500_start_clone.sh + +local backup_directory=$BUILD_DIR/outputfs/$NETFS_PREFIX + +# BLOCKCLONE progs could be handled here +case "$(basename ${BLOCKCLONE_PROG})" in + (ntfsclone) + ntfsclone -q --save-image $BLOCKCLONE_COMMAND_OPTS \ + -O $backuparchive $BLOCKCLONE_SOURCE_DEV + ;; + (dd) + # This does not work yet, only a placeholder + dd $BLOCKCLONE_COMMAND_OPTS + ;; +esac + +# Save MBR data if $BLOCKCLONE_SAVE_MBR_DEV is set (non-empty) +# ${BACKUP_PROG_ARCHIVE}_mbr.img will be used for partitioning (quick an dirty) +# Dualboot on single disk DOES NOT YET WORK !!! +if [ $BLOCKCLONE_SAVE_MBR_DEV ]; then + Log "Creating MBR image" + dd if=$BLOCKCLONE_SAVE_MBR_DEV of=$backup_directory/${BACKUP_PROG_ARCHIVE}_mbr.img bs=512 count=1 + StopIfError "Failed to save MBR image" +fi diff --git a/usr/share/rear/backup/BLOCKCLONE/default/970_remove_lock.sh b/usr/share/rear/backup/BLOCKCLONE/default/970_remove_lock.sh new file mode 120000 index 0000000000..e904d3bfa2 --- /dev/null +++ b/usr/share/rear/backup/BLOCKCLONE/default/970_remove_lock.sh @@ -0,0 +1 @@ +../../NETFS/default/970_remove_lock.sh \ No newline at end of file diff --git a/usr/share/rear/backup/BLOCKCLONE/default/980_umount_NETFS_dir.sh b/usr/share/rear/backup/BLOCKCLONE/default/980_umount_NETFS_dir.sh new file mode 120000 index 0000000000..2c29cb573c --- /dev/null +++ b/usr/share/rear/backup/BLOCKCLONE/default/980_umount_NETFS_dir.sh @@ -0,0 +1 @@ +../../NETFS/default/980_umount_NETFS_dir.sh \ No newline at end of file diff --git a/usr/share/rear/conf/default.conf b/usr/share/rear/conf/default.conf index 514cd4f3cb..b9a2ecad8e 100644 --- a/usr/share/rear/conf/default.conf +++ b/usr/share/rear/conf/default.conf @@ -100,25 +100,12 @@ OS_VERSION=none # keep the build area after we are done ? (BOOL) KEEP_BUILD_DIR="" -# No default workflows. This variable is filled in where the workflows are defined +# no default workflows. This variable is filled in where the worklflows are defined # without the empty string as initial value WORKFLOWS and LOCKLESS_WORKFLOWS would # be unbound variables that would result an error exit if 'set -eu' is used: WORKFLOWS=("") -# Allow some workflows to not lock and use a separate logfile named 'LOGFILE.lockless'. -# The LOCKLESS_WORKFLOWS array gets filled during runtime as needed by the various -# usr/share/rear/lib/WORKFLOW-workflow.sh scripts. Currently the following workflows -# add themselves to the LOCKLESS_WORKFLOWS array: checklayout dump help +# allow some workflows to not lock, also generates a separate log LOCKLESS_WORKFLOWS=("") -# SIMULTANEOUS_RUNNABLE_WORKFLOWS are also allowed to run simultaneously -# but cannot use LOGFILE.lockless as the LOCKLESS_WORKFLOWS. -# Instead the SIMULTANEOUS_RUNNABLE_WORKFLOWS get a LOGFILE with PID -# because simultaneously runnable workflows require unique logfile names -# so that the PID is interposed in the LOGFILE value from default.conf above, -# i.e. by default SIMULTANEOUS_RUNNABLE_WORKFLOWS use during runtime -# a logfile named /var/log/rear/rear-$HOSTNAME.$$.log that gets -# at the end copied to a final possibly used-defined LOGFILE, -# see /usr/sbin/rear and https://github.com/rear/rear/issues/1102 -SIMULTANEOUS_RUNNABLE_WORKFLOWS=( 'mkbackuponly' 'restoreonly' ) # default backup and output targets BACKUP=REQUESTRESTORE @@ -724,6 +711,14 @@ BORGBACKUP_PRUNE_WEEKLY= BORGBACKUP_PRUNE_MONTHLY= BORGBACKUP_PRUNE_YEARLY= +## +# BACKUP=BLOCKCLONE +## +BLOCKCLONE_SOURCE_DEV="" +BLOCKCLONE_PROG="" +BLOCKCLONE_COMMAND_OPTS="" +BLOCKCLONE_SAVE_MBR_DEV="" + # Environment variables # Borg is using couple of environment variables which can influence its behavior. # You can make use of them by putting 'export BORG_var_name="var_value"' diff --git a/usr/share/rear/prep/BLOCKCLONE/default/050_check_NETFS_requirements.sh b/usr/share/rear/prep/BLOCKCLONE/default/050_check_NETFS_requirements.sh new file mode 120000 index 0000000000..af1512d686 --- /dev/null +++ b/usr/share/rear/prep/BLOCKCLONE/default/050_check_NETFS_requirements.sh @@ -0,0 +1 @@ +../../NETFS/default/050_check_NETFS_requirements.sh \ No newline at end of file diff --git a/usr/share/rear/prep/BLOCKCLONE/default/060_mount_NETFS_path.sh b/usr/share/rear/prep/BLOCKCLONE/default/060_mount_NETFS_path.sh new file mode 120000 index 0000000000..da4c280435 --- /dev/null +++ b/usr/share/rear/prep/BLOCKCLONE/default/060_mount_NETFS_path.sh @@ -0,0 +1 @@ +../../NETFS/default/060_mount_NETFS_path.sh \ No newline at end of file diff --git a/usr/share/rear/prep/BLOCKCLONE/default/070_set_backup_archive.sh b/usr/share/rear/prep/BLOCKCLONE/default/070_set_backup_archive.sh new file mode 120000 index 0000000000..cdbdc31fab --- /dev/null +++ b/usr/share/rear/prep/BLOCKCLONE/default/070_set_backup_archive.sh @@ -0,0 +1 @@ +../../NETFS/default/070_set_backup_archive.sh \ No newline at end of file diff --git a/usr/share/rear/prep/BLOCKCLONE/default/100_check_nfs_version.sh b/usr/share/rear/prep/BLOCKCLONE/default/100_check_nfs_version.sh new file mode 120000 index 0000000000..e5892a81e6 --- /dev/null +++ b/usr/share/rear/prep/BLOCKCLONE/default/100_check_nfs_version.sh @@ -0,0 +1 @@ +../../NETFS/default/100_check_nfs_version.sh \ No newline at end of file diff --git a/usr/share/rear/prep/BLOCKCLONE/default/980_umount_NETFS_dir.sh b/usr/share/rear/prep/BLOCKCLONE/default/980_umount_NETFS_dir.sh new file mode 120000 index 0000000000..2c29cb573c --- /dev/null +++ b/usr/share/rear/prep/BLOCKCLONE/default/980_umount_NETFS_dir.sh @@ -0,0 +1 @@ +../../NETFS/default/980_umount_NETFS_dir.sh \ No newline at end of file