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:
parent
9af3d34106
commit
6cb85b47e9
@ -38,6 +38,7 @@ DRIVER_PATH=$(dirname $0)
|
|||||||
source $TMCOMMON
|
source $TMCOMMON
|
||||||
source ${DRIVER_PATH}/../../datastore/libfs.sh
|
source ${DRIVER_PATH}/../../datastore/libfs.sh
|
||||||
source ${DRIVER_PATH}/../../etc/tm/fs_lvm/fs_lvm.conf
|
source ${DRIVER_PATH}/../../etc/tm/fs_lvm/fs_lvm.conf
|
||||||
|
source ${DRIVER_PATH}/../../scripts_common.sh
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Set dst path and dir
|
# Set dst path and dir
|
||||||
@ -150,7 +151,7 @@ CLONE_CMD=$(cat <<EOF
|
|||||||
rm -f "$DST_PATH"
|
rm -f "$DST_PATH"
|
||||||
ln -s "$DEV" "$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
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ fi
|
|||||||
|
|
||||||
DRIVER_PATH=$(dirname $0)
|
DRIVER_PATH=$(dirname $0)
|
||||||
|
|
||||||
|
source ${DRIVER_PATH}/../../scripts_common.sh
|
||||||
|
|
||||||
source $TMCOMMON
|
source $TMCOMMON
|
||||||
source $SSH_RC
|
source $SSH_RC
|
||||||
source $SSH_UTILS
|
source $SSH_UTILS
|
||||||
@ -70,10 +72,10 @@ if [ -n "$REPLICA_HOST" ]; then
|
|||||||
ssh $REPLICA_HOST "mkdir -p $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
|
ssh $REPLICA_HOST "mkdir -p $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
|
||||||
|
|
||||||
cd $VM_DIR
|
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} | \
|
-cSf - ${DISK_NAME}.snap/${SNAP_ID} | \
|
||||||
ssh $REPLICA_SSH_OPTS ${REPLICA_HOST} \
|
ssh $REPLICA_SSH_OPTS ${REPLICA_HOST} \
|
||||||
"tar xSf - -C $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
|
"$TAR -xSf - -C $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
|
||||||
fi
|
fi
|
||||||
EOT
|
EOT
|
||||||
)
|
)
|
||||||
|
@ -38,6 +38,7 @@ source $TMCOMMON
|
|||||||
source $SSH_RC
|
source $SSH_RC
|
||||||
source $SSH_UTILS
|
source $SSH_UTILS
|
||||||
source ${DRIVER_PATH}/../../etc/vmm/kvm/kvmrc
|
source ${DRIVER_PATH}/../../etc/vmm/kvm/kvmrc
|
||||||
|
source ${DRIVER_PATH}/../../scripts_common.sh
|
||||||
|
|
||||||
SRC_PATH=$(arg_path $SRC NOFIX)
|
SRC_PATH=$(arg_path $SRC NOFIX)
|
||||||
SRC_HOST=$(arg_host $SRC)
|
SRC_HOST=$(arg_host $SRC)
|
||||||
@ -79,10 +80,10 @@ if [ -n "$REPLICA_HOST" ]; then
|
|||||||
ssh $REPLICA_HOST "mkdir -p $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
|
ssh $REPLICA_HOST "mkdir -p $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
|
||||||
|
|
||||||
cd $VM_DIR
|
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} | \
|
-cSf - ${DISK_NAME}.snap/${SNAP_ID} | \
|
||||||
ssh $REPLICA_SSH_OPTS ${REPLICA_HOST} \
|
ssh $REPLICA_SSH_OPTS ${REPLICA_HOST} \
|
||||||
"tar xSf - -C $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
|
"$TAR -xSf - -C $REPLICA_RECOVERY_SNAPS_DIR/$VMID"
|
||||||
fi
|
fi
|
||||||
EOT
|
EOT
|
||||||
)
|
)
|
||||||
|
@ -26,6 +26,8 @@ fi
|
|||||||
|
|
||||||
. $SSH_RC
|
. $SSH_RC
|
||||||
|
|
||||||
|
source ${ONE_LOCAL_VAR}/remotes/scripts_common.sh
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Returns REPLICA_HOST attribute from DATASTORE template
|
# Returns REPLICA_HOST attribute from DATASTORE template
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -105,8 +107,8 @@ function rsync_img_to_replica {
|
|||||||
LOCK="replica-$REPLICA_HOST-${IMG_PATH//\//-}"
|
LOCK="replica-$REPLICA_HOST-${IMG_PATH//\//-}"
|
||||||
RSYNC_CMD=$(cat <<EOF
|
RSYNC_CMD=$(cat <<EOF
|
||||||
set -e -o pipefail
|
set -e -o pipefail
|
||||||
tar -cSf - ${IMG_PATH}* | \
|
$TAR -cSf - ${IMG_PATH}* | \
|
||||||
ssh $REPLICA_SSH_FE_OPTS $REPLICA_HOST 'tar xSf - -C / '
|
ssh $REPLICA_SSH_FE_OPTS $REPLICA_HOST '$TAR -xSf - -C / '
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
exclusive "$LOCK" "$LOCK_TIMEOUT" \
|
exclusive "$LOCK" "$LOCK_TIMEOUT" \
|
||||||
|
@ -151,7 +151,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# do initial rsync
|
# 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"
|
"Failed to rsync disk $DISK_PATH to $DEST_HOST:$DISK_PATH"
|
||||||
|
|
||||||
elif [ "$FORMAT" = "qcow2" ]; then
|
elif [ "$FORMAT" = "qcow2" ]; then
|
||||||
@ -168,7 +168,7 @@ else
|
|||||||
|
|
||||||
# copy disk snapshots
|
# copy disk snapshots
|
||||||
if [ -d "${DISK_PATH}.snap" ] || [ -L "${DISK_PATH}.snap" ]; then
|
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"
|
"Failed to rsync disk snapshot ${DISK_PATH}.snap to $DEST_HOST"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ else
|
|||||||
|
|
||||||
# copy vm.xml and ds.xml from the $VM_DIR
|
# copy vm.xml and ds.xml from the $VM_DIR
|
||||||
if ls $VM_DIR/*.xml > /dev/null; then
|
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"
|
"Failed to copy xml files to $DEST_HOST"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
for DISK in $RAW_DISKS; do
|
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"
|
"Failed to rsync disk $DISK to $DEST_HOST:$DISK"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user