You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.2 KiB
61 lines
1.2 KiB
#!/bin/bash
|
|
|
|
## Load action gets a first argument a DIRECTORY holding the necessary files.
|
|
##
|
|
##
|
|
|
|
if [ -z "$SERVICE_DATASTORE" ]; then
|
|
echo "This script is meant to be run through 'compose' to work properly." >&2
|
|
exit 1
|
|
fi
|
|
|
|
usage="$exname [-h|--help] DBNAME DEST"
|
|
|
|
dbname=
|
|
postgis=
|
|
while [ "$1" ]; do
|
|
case "$1" in
|
|
"--help"|"-h")
|
|
print_usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
[ -z "$dbname" ] && { dbname=$1 ; shift ; continue ; }
|
|
[ -z "$DEST" ] && { DEST=$1 ; shift ; continue ; }
|
|
err "Unexpected argument '$1'."
|
|
exit 1
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
|
|
if [ -z "$dbname" ]; then
|
|
err "You must provide a source database name as first argument."
|
|
print_usage
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "$DEST" ]; then
|
|
err "You must provide a dest file as second argument."
|
|
print_usage
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$dbname" == *"@"* ]]; then
|
|
IFS="@" read user dbname < <(echo "$dbname")
|
|
fi
|
|
|
|
. "$CHARM_PATH"/lib/common
|
|
|
|
set -e
|
|
|
|
if ! db_has_database "$dbname"; then
|
|
err "Can't find database '$dbname'."
|
|
exit 1
|
|
fi
|
|
|
|
PGM cp "$dbname" "$DEST" || {
|
|
die "pgm command failed !"
|
|
}
|
|
info "Saved database '$dbname' into '$DEST'."
|