3
# This is a simple wrapper around globus-url-copy to perform a directory copy
4
# using tar streamed via gridftp.
6
# See http://www.mcs.anl.gov/~bresnaha/Stretch/ for other interesting ways
7
# to use this feature with any application that pipes data.
9
# In order to work with this feature, a server needs to be configured to
10
# enable the popen driver and tar with the following configuration options:
11
# -fs-whitelist file,popen,ordering -popen-whitelist tar:/bin/tar
14
## path or alias for gnu tar
18
## parse the source and dest args
19
if [ "X$1" = "X" -o "X$2" = "X" ]; then
20
echo "Usage: globus-dir-copy [source URL or path] [destination URL or path]"
25
SRC_PATH=${SRC_URL#*://*/}
26
if [ "${SRC_PATH}" != "${SRC_URL}" ]; then SRC_PATH=/$SRC_PATH; fi
27
SRC_TARGET=${SRC_PATH##*/}
28
SRC_PATH=${SRC_PATH%/*}
29
if [ "${SRC_PATH}X" = "X" ]; then SRC_PATH=.; fi
32
DEST_PATH=${DEST_URL#*://*/}
33
if [ "${DEST_PATH}" != "${DEST_URL}" ]; then DEST_PATH=/$DEST_PATH; fi
34
if [ "${DEST_PATH}X" = "X" ]; then DEST_PATH=.; fi
38
## find transfer mode: get, put, third paty, or local.
63
# The path in the url doesn't affect the transfer, but include the full path
64
# so directory creation (-cd) will remain functional, and add TARSTREAM so
65
# server logs will reflect what is going on.
69
#####################################################################
71
#####################################################################
72
test -d "$DEST_PATH" || mkdir -p "$DEST_PATH" 2>/dev/null
73
globus-url-copy ${3} ${4} ${5} -src-pipe "${SERVER_TAR} cf - -C ${SRC_PATH} ${SRC_TARGET}" ${SRC_URL}/TARSTREAM - | ${LOCAL_TAR} xf - -C ${DEST_PATH}
76
#####################################################################
78
#####################################################################
80
${LOCAL_TAR} cf - -C ${SRC_PATH} ${SRC_TARGET} | globus-url-copy -cd ${3} ${4} ${5} -dst-pipe "${SERVER_TAR} xf - -C ${DEST_PATH}" - ${DEST_URL}/TARSTREAM
83
#####################################################################
85
#####################################################################
87
globus-url-copy -cd ${3} ${4} ${5} -src-pipe "${SERVER_TAR} cf - -C ${SRC_PATH} ${SRC_TARGET}" -dst-pipe "${SERVER_TAR} xf - -C ${DEST_PATH}" ${SRC_URL}/TARSTREAM ${DEST_URL}/TARSTREAM
90
#####################################################################
92
#####################################################################
94
test -d "$DEST_PATH" || mkdir -p "$DEST_PATH" 2>/dev/null
95
${LOCAL_TAR} cf - -C ${SRC_PATH} ${SRC_TARGET} | ${LOCAL_TAR} xf - -C ${DEST_PATH}