-
Notifications
You must be signed in to change notification settings - Fork 0
/
bpdownload
45 lines (41 loc) · 1.43 KB
/
bpdownload
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Download Data from BigPurple
bpdownload() {
# Initialize variables
local remote_project_dir=""
local local_data_dir=""
local remote_user="${REMOTE_USER:-mm12865}"
local remote_host="${REMOTE_HOST:-bigpurple.nyumc.org}"
# Function to display help
show_help() {
echo "Usage: bpdownload -r <remote_project_dir> -l <local_data_dir>"
echo "Options:"
echo " -r <remote_project_dir> Specify the remote project directory"
echo " -l <local_data_dir> Specify the local data directory"
echo " -h Show this help message"
}
# Parse options
while getopts "r:l:h" opt; do
case $opt in
r) remote_project_dir="$OPTARG" ;;
l) local_data_dir="$OPTARG" ;;
h) show_help
return 0 ;;
*) show_help
return 1 ;;
esac
done
# Check if required arguments are provided
if [ -z "$remote_project_dir" ] || [ -z "$local_data_dir" ]; then
show_help
return 1
fi
# Use rsync to download the data folder
rsync -avz --progress "$remote_user@$remote_host:$remote_project_dir" "$local_data_dir"
local rsync_exit_code=$?
if [ $rsync_exit_code -eq 0 ]; then
echo "Data folder downloaded successfully."
else
echo "Error: Failed to download data folder. rsync exit code: $rsync_exit_code"
return $rsync_exit_code
fi
}