Skip to content

Commit ef55e0d

Browse files
committed
tm/mv - enhance system ds dir move on same host
Signed-off-by: Kristian Feldsam <feldsam@gmail.com>
1 parent d5d15ad commit ef55e0d

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

tm/3par/mv

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,29 @@ if [ `is_disk $DST_PATH` -eq 0 ]; then
100100

101101
ssh_exec_and_log "$DST_HOST" "rm -rf '$DST_PATH'" \
102102
"Error removing target path to prevent overwrite errors"
103-
104-
TAR_SSH=$(cat <<EOF
105-
set -e -o pipefail
106-
107-
$TAR -C $SRC_DS_DIR --sparse -cf - $SRC_VM_DIR | $SSH $DST_HOST '$TAR -C $DST_DIR --sparse -xf -'
108-
rm -rf $SRC_PATH
103+
104+
if [ "$SRC_HOST" == "$DST_HOST" ]; then
105+
log "Moving on same host only between datastores"
106+
107+
MV_CMD=$(cat <<EOF
108+
set -e -o pipefail
109+
110+
mv $SRC_PATH $DST_PATH
111+
EOF
112+
)
113+
ssh_exec_and_log "$SRC_HOST" "$MV_CMD" "Error moving disk directory to new location"
114+
else
115+
TAR_SSH=$(cat <<EOF
116+
set -e -o pipefail
117+
118+
$TAR -C $SRC_DS_DIR --sparse -cf - $SRC_VM_DIR | $SSH $DST_HOST '$TAR -C $DST_DIR --sparse -xf -'
119+
rm -rf $SRC_PATH
109120
EOF
110121
)
111122

112-
ssh_exec_and_log "$SRC_HOST" "$TAR_SSH" "Error copying disk directory to target host"
113-
123+
ssh_exec_and_log "$SRC_HOST" "$TAR_SSH" "Error copying disk directory to target host"
124+
fi
125+
114126
exit 0
115127
fi
116128

0 commit comments

Comments
 (0)