-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrsync.sh
executable file
·51 lines (44 loc) · 1.46 KB
/
rsync.sh
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
46
47
48
49
50
51
#!/bin/bash
# ANSI color codes
RED='\033[0;31m' # Red
G='\033[0;32m' # Green
NC='\033[0m' # Reset color
# Display script usage
function show_usage {
echo "Rsync script syncs the src and experiments directories to the host. Can also sync a single file."
echo "Usage: $0 [-f] [-h]"
echo " -f: rsync one file with filename as argument"
echo " -h: Display this help message"
exit 1
}
# Default values
src="./src"
experiments="./experiments"
remote_dir="[email protected]:/home/krzysztofj/distributional-sac/"
# Parse command-line options
while getopts ":f:h" opt; do
case $opt in
f)
echo -e "${G}Syncing file $OPTARG to ${remote_dir}${NC}"
rsync -av "$OPTARG" "$remote_dir"
exit 0
;;
h)
show_usage
;;
\?)
echo -e "${RED}Error: Invalid option: -${OPTARG}${NC}"
show_usage
;;
esac
done
# Perform rsync of src and experiments directories. Files on receiver side not present in sender side are deleted.
echo -e "${G}Syncing $src to $remote_dir${NC}"
rsync -av --delete --exclude='__pycache__' --exclude="./outputs/" "$src" "$remote_dir"
rsync -av --delete "$experiments/configs" "$remote_dir/experiments"
# Get results from the host
echo -e "${G}Syncing results from $remote_dir to $experiments${NC}"
scp -r "$remote_dir/experiments/results" "$experiments"
# copy csv_drqv2 from host
echo -e "${G}Syncing csv_drqv2 from $remote_dir to $experiments${NC}"
scp -r "$remote_dir/csv_drqv2" "$experiments"