Add a script to load dumps into db

This commit is contained in:
Rafa de la Torre 2015-11-05 18:37:21 +01:00
parent dae0fa38ab
commit faf5514d2e

43
geocoder/geocoder_restore_dump Executable file
View File

@ -0,0 +1,43 @@
#!/bin/bash
function usage() {
cat <<EOF
Usage:
$(basename $0) DBUSER DBNAME *.sql
E.g:
$(basename $0) development_cartodb_user_87ddf981-25c7-4538-9910-0eb4342f2483 cartodb_dev_user_87ddf981-25c7-4538-9910-0eb4342f2483_db dumps/*.sql
EOF
}
if [ "$#" -lt "3" ]; then
usage
exit 1
fi
DBUSER=$1
DBNAME=$2
shift; shift;
DUMP_FILES="$@"
echo
echo "About to import the following files: ${DUMP_FILES}"
for i in $DUMP_FILES; do
echo
echo "Importing ${i}..."
psql \
--username=${DBUSER} \
--dbname=${DBNAME} \
--set=ON_ERROR_STOP=on \
--single-transaction \
--file=${i} || exit 1
echo "Done with ${i}."
echo
done
echo
echo "** Everything OK **"