Skip to content

Commit b282044

Browse files
Enhance dtn_download.sh for improved usability and logging
- Updated usage instructions to include a dry run option and clarified parallel job settings. - Changed default parallel jobs from 8 to 4 for better performance. - Added logging capabilities to track transfer jobs and their outputs. - Improved user feedback during directory discovery and transfer completion.
1 parent 8588f62 commit b282044

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

scripts/gromacs/data_transfer/sherlock/dtn_download.sh

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,30 @@
33
set -euo pipefail
44

55
usage() {
6-
echo "Usage: ${0##*/} [-j <n>] REMOTE_DIR LOCAL_DIR" >&2
6+
cat >&2 <<EOF
7+
Usage: ${0##*/} [-j <n>] [-n] REMOTE_DIR LOCAL_DIR
8+
9+
Options:
10+
-j <n> Number of parallel rsync jobs (default: 4)
11+
-n Dry run (show what would be transferred)
12+
13+
Example:
14+
${0##*/} -j 4 /scratch/users/\$USER/md_runs /data/local/md_runs
15+
EOF
716
exit 1
817
}
918

1019
LOGIN_HOST="sherlock-plain"
1120
DTN_HOST="sherlock-dtn"
12-
JOBS=8
21+
JOBS=4
22+
DRY_RUN=""
23+
24+
SSH_OPTS="ssh -T -c aes128-gcm@openssh.com -o Compression=no -o ServerAliveInterval=60"
1325

14-
while getopts "j:" opt; do
26+
while getopts "j:n" opt; do
1527
case $opt in
1628
j) JOBS="$OPTARG" ;;
29+
n) DRY_RUN="--dry-run" ;;
1730
*) usage ;;
1831
esac
1932
done
@@ -25,6 +38,7 @@ LOCAL_DIR="$2"
2538

2639
mkdir -p "$LOCAL_DIR"
2740

41+
echo "=== Discovering subdirectories in $REMOTE_DIR ==="
2842
mapfile -t SUBDIRS < <(
2943
ssh -n "$LOGIN_HOST" "find \"$REMOTE_DIR\" -mindepth 1 -maxdepth 1 -type d -printf '%f\n'" | sort
3044
)
@@ -33,8 +47,17 @@ mapfile -t SUBDIRS < <(
3347
exit 1
3448
}
3549

36-
parallel -j "$JOBS" \
37-
rsync -ahP --append-verify \
50+
echo "=== Found ${#SUBDIRS[@]} subdirectories, transferring with $JOBS parallel jobs ==="
51+
52+
LOGDIR="$LOCAL_DIR/.transfer_logs"
53+
mkdir -p "$LOGDIR"
54+
55+
parallel -j "$JOBS" --bar --joblog "$LOGDIR/joblog.tsv" \
56+
rsync -ahP --append-verify $DRY_RUN \
57+
-e "'$SSH_OPTS'" \
58+
--log-file="'$LOGDIR/{}.log'" \
3859
"$DTN_HOST:$REMOTE_DIR/{}/" \
3960
"$LOCAL_DIR/{}/" \
4061
::: "${SUBDIRS[@]}"
62+
63+
echo "=== Transfer complete. Logs in $LOGDIR ==="

0 commit comments

Comments
 (0)