sync.sh 948 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env bash

REMOTE="vaa2:/data/common/GEOCAT_ANCILLARY_DATA/"
LOCAL="data/"

if [ ! -d ${LOCAL} ]; then
    echo "${LOCAL} not found. This script expects to be run from the geocat-ancillary/ directory."
    exit 1
fi

list_updated_files() {
    rsync --dry-run --copy-links -rcv ${REMOTE} ${LOCAL} | \
        grep -v "receiving" | \
        grep -v "bytes/sec" | \
        grep -v "DRY RUN"
}

echo "Retrieving a list of updated & new files from:"
Nick Bearson's avatar
Nick Bearson committed
19
echo -e "\e[96m${REMOTE}\e[0m"
20
21
22
23
echo "Get a ☕ , this could take a bit..."

for file in $(list_updated_files); do
    echo ""
Nick Bearson's avatar
Nick Bearson committed
24
25
26
27
28
29
30
31
32

    if [ -f ${LOCAL}${file} ]; then
      status="\e[93mupdated\e[0m"
    else
      status="\e[92mnew\e[0m"
    fi

    echo -e "${file} is ${status}. Download?"

33
34
    select yn in "Yes" "No"; do
        case ${yn} in
35
            Yes ) rsync -z --progress --copy-links ${REMOTE}${file} ${LOCAL}${file}; break;;
36
37
38
39
            No ) break;;
        esac
    done
done