summaryrefslogtreecommitdiff
path: root/dumps/fetch-local.sh
blob: 2dccc83118fe334ca384d756403634c23d4648be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/bash

if [ -z ${LIGA_LOCAL_DUMP_PATTERN+x} ]
then
    echo 'Local dumps not configured, skipping'
else
    find ${LIGA_LOCAL_DUMP_PATH} -path ${LIGA_LOCAL_DUMP_PATTERN} | sort | uniq | cut -d/ -f 1-4 | uniq | while read LOCAL_DUMP_DIR
    do
        LOCAL_DUMP=$(find ${LOCAL_DUMP_DIR} -name *.sql -exec ls -t1 {} + | head -n1 | cut -d' ' -f 10)
        TARGET_DUMP=$(basename ${LOCAL_DUMP})
        TARGET_DUMP=${TARGET_DUMP%%-*}
        cp "${LOCAL_DUMP}" dumps/sync/${TARGET_DUMP}.sql
        echo "${LOCAL_DUMP}"
    done
fi