1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-25 23:21:29 +03:00

B #-: fixing customizable tar commands (#2570)

Signed-off-by: Neal Hansen <nhansen@opennebula.io>
This commit is contained in:
Neal 2023-03-29 03:09:10 -06:00 committed by GitHub
parent 9af3d34106
commit 6cb85b47e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 11 deletions

View File

@ -38,6 +38,7 @@ DRIVER_PATH=$(dirname $0)
source $TMCOMMON
source ${DRIVER_PATH}/../../datastore/libfs.sh
source ${DRIVER_PATH}/../../etc/tm/fs_lvm/fs_lvm.conf
source ${DRIVER_PATH}/../../scripts_common.sh
#-------------------------------------------------------------------------------
# Set dst path and dir
@ -150,7 +151,7 @@ CLONE_CMD=$(cat <<EOF
rm -f "$DST_PATH"
ln -s "$DEV" "$DST_PATH"
$SSH -n $SRC_HOST "$TAR -cSO $SRC_PATH 2> /dev/null" | tar -xO 2> /dev/null > "$DEV"
$SSH -n $SRC_HOST "$TAR -cSO $SRC_PATH 2> /dev/null" | $TAR -xO 2> /dev/null > "$DEV"
EOF
)

View File

@ -34,6 +34,8 @@ fi
DRIVER_PATH=$(dirname $0)
source ${DRIVER_PATH}/../../scripts_common.sh
source $TMCOMMON
source $SSH_RC
source $SSH_UTILS
@ -70,10 +72,10 @@ if [ -n "$REPLICA_HOST" ]; then
ssh $REPLICA_HOST "mkdir -p $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
cd $VM_DIR
tar --transform="flags=r;s|${DISK_NAME}.snap/${SNAP_ID}|${DISK_NAME}.replica_snap|" \
$TAR --transform="flags=r;s|${DISK_NAME}.snap/${SNAP_ID}|${DISK_NAME}.replica_snap|" \
-cSf - ${DISK_NAME}.snap/${SNAP_ID} | \
ssh $REPLICA_SSH_OPTS ${REPLICA_HOST} \
"tar xSf - -C $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
"$TAR -xSf - -C $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
fi
EOT
)

View File

@ -38,6 +38,7 @@ source $TMCOMMON
source $SSH_RC
source $SSH_UTILS
source ${DRIVER_PATH}/../../etc/vmm/kvm/kvmrc
source ${DRIVER_PATH}/../../scripts_common.sh
SRC_PATH=$(arg_path $SRC NOFIX)
SRC_HOST=$(arg_host $SRC)
@ -79,10 +80,10 @@ if [ -n "$REPLICA_HOST" ]; then
ssh $REPLICA_HOST "mkdir -p $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
cd $VM_DIR
tar --transform="flags=r;s|${DISK_NAME}.snap/${SNAP_ID}|${DISK_NAME}.replica_snap|" \
$TAR --transform="flags=r;s|${DISK_NAME}.snap/${SNAP_ID}|${DISK_NAME}.replica_snap|" \
-cSf - ${DISK_NAME}.snap/${SNAP_ID} | \
ssh $REPLICA_SSH_OPTS ${REPLICA_HOST} \
"tar xSf - -C $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
"$TAR -xSf - -C $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
fi
EOT
)

View File

@ -26,6 +26,8 @@ fi
. $SSH_RC
source ${ONE_LOCAL_VAR}/remotes/scripts_common.sh
# ------------------------------------------------------------------------------
# Returns REPLICA_HOST attribute from DATASTORE template
# ------------------------------------------------------------------------------
@ -105,8 +107,8 @@ function rsync_img_to_replica {
LOCK="replica-$REPLICA_HOST-${IMG_PATH//\//-}"
RSYNC_CMD=$(cat <<EOF
set -e -o pipefail
tar -cSf - ${IMG_PATH}* | \
ssh $REPLICA_SSH_FE_OPTS $REPLICA_HOST 'tar xSf - -C / '
$TAR -cSf - ${IMG_PATH}* | \
ssh $REPLICA_SSH_FE_OPTS $REPLICA_HOST '$TAR -xSf - -C / '
EOF
)
exclusive "$LOCK" "$LOCK_TIMEOUT" \

View File

@ -151,7 +151,7 @@ else
fi
# do initial rsync
multiline_exec_and_log "tar -cSf - $DISK_PATH | $SSH $DEST_HOST 'tar xSf - -C / '" \
multiline_exec_and_log "$TAR -cSf - $DISK_PATH | $SSH $DEST_HOST '$TAR -xSf - -C / '" \
"Failed to rsync disk $DISK_PATH to $DEST_HOST:$DISK_PATH"
elif [ "$FORMAT" = "qcow2" ]; then
@ -168,7 +168,7 @@ else
# copy disk snapshots
if [ -d "${DISK_PATH}.snap" ] || [ -L "${DISK_PATH}.snap" ]; then
multiline_exec_and_log "tar -cSf - $DISK_PATH.snap | $SSH $DEST_HOST 'tar xSf - -C / '" \
multiline_exec_and_log "$TAR -cSf - $DISK_PATH.snap | $SSH $DEST_HOST '$TAR -xSf - -C / '" \
"Failed to rsync disk snapshot ${DISK_PATH}.snap to $DEST_HOST"
fi
@ -182,7 +182,7 @@ else
# copy vm.xml and ds.xml from the $VM_DIR
if ls $VM_DIR/*.xml > /dev/null; then
multiline_exec_and_log "tar -cSf - $VM_DIR/*.xml | $SSH $DEST_HOST 'tar xSf - -C / '" \
multiline_exec_and_log "$TAR -cSf - $VM_DIR/*.xml | $SSH $DEST_HOST '$TAR -xSf - -C / '" \
"Failed to copy xml files to $DEST_HOST"
fi
@ -204,7 +204,7 @@ else
fi
for DISK in $RAW_DISKS; do
multiline_exec_and_log "tar -cSf - $DISK | $SSH $DEST_HOST 'tar xSf - -C / '" \
multiline_exec_and_log "$TAR -cSf - $DISK | $SSH $DEST_HOST '$TAR -xSf - -C / '" \
"Failed to rsync disk $DISK to $DEST_HOST:$DISK"
done
fi