aboutsummaryrefslogtreecommitdiffstats
path: root/pgaas/src/stage/opt/app/pgaas/bin/pg_copy
diff options
context:
space:
mode:
Diffstat (limited to 'pgaas/src/stage/opt/app/pgaas/bin/pg_copy')
-rwxr-xr-xpgaas/src/stage/opt/app/pgaas/bin/pg_copy97
1 files changed, 0 insertions, 97 deletions
diff --git a/pgaas/src/stage/opt/app/pgaas/bin/pg_copy b/pgaas/src/stage/opt/app/pgaas/bin/pg_copy
deleted file mode 100755
index ee2272b..0000000
--- a/pgaas/src/stage/opt/app/pgaas/bin/pg_copy
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/bin/bash
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this code except in compliance
-# with the License. You may obtain a copy of the License
-# at http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# permissions and limitations under the License.
-
-
-if [ -d /opt/app/postgresql-9.5.2 ]
-then PGDIR=/opt/app/postgresql-9.5.2
-elif [ -d /usr/lib/postgresql/9.6 ]
-then PGDIR=/usr/lib/postgresql/9.6
-elif [ -d /usr/lib/postgresql/9.5 ]
-then PGDIR=/usr/lib/postgresql/9.5
-else echo PostgreSQL bin directory not found 1>&2; exit 1
-fi
-
-export PATH=$PATH:$PGDIR/bin
-
-# pg_dump -C -h localhost -U localuser dbname | psql -h remotehost -U remoteuser dbname
-# pg_dump -C -h remotehost -U remoteuser dbname | psql -h localhost -U localuser dbname
-
-usage()
-{
- exec 1>&2
- [ $# -gt 0 ] && echo "$@"
- b=$(basename $0)
- echo "Usage: $b [-v] -H fromhost [-P fromport] -U fromuser -D fromdb [-A | -S] -h tohost [-p toport] -h touser -d todb"
- echo "Copy a database from a one host to a another"
- echo -e "-H\tFQDN of host to copy from"
- echo -e "-P\tport of database being copied from"
- echo -e "-U\tUSER to login as on remote host being copied from"
- echo -e "-W\tPASSWORD to use to login as on remote host being copied from"
- echo -e "-D\tDB database on host to be copied from"
- echo -e "-A\tcopy data only"
- echo -e "-S\tcopy schema only"
- echo -e "-h\tFQDN of host to copy to"
- echo -e "-p\tport of database being copied to"
- echo -e "-u\tUSER to login as on host being copied to"
- echo -e "-w\tPASSWORD to use to login as on host being copied to"
- echo -e "-d\tDB database on host to be copied to"
- exit 1
-}
-
-REMOTEDATAONLY=
-REMOTESCHEMAONLY=
-REMOTEHOST=
-REMOTEPORT=
-REMOTEUSER=
-REMOTEPASSWORD=
-REMOTEDB=
-LOCALHOST=
-LOCALPORT=
-LOCALUSER=
-LOCALDB=
-LOCALPASSWORD
-
-while getopts ASH:P:U:W:D:h:p::u:w:d: c
-do
- case $c in
- A ) REMOTEDATAONLY=-a ;;
- S ) REMOTESCHEMAONLY=-s ;;
- H ) REMOTEHOST=$OPTARG ;;
- P ) REMOTEPORT=$OPTARG ;;
- U ) REMOTEUSER=$OPTARG ;;
- W ) REMOTEPASSWORD=$OPTARG ;;
- D ) REMOTEDB=$OPTARG;;
- h ) LOCALHOST=$OPTARG ;;
- p ) LOCALPORT=$OPTARG ;;
- u ) LOCALUSER=$OPTARG ;;
- w ) LOCALPASSWORD=$OPTARG ;;
- d ) LOCALDB=$OPTARG;;
- esac
-done
-
-
-[ -z "$REMOTEHOST" ] && usage "Missing -H option"
-[ -z "$REMOTEPORT" ] && usage "Missing -P option"
-[ -z "$REMOTEUSER" ] && usage "Missing -U option"
-[ -z "$REMOTEDB" ] && usage "Missing -D option"
-[ -z "$REMOTEPASSWORD" ] && usage "Missing -W option"
-[ -z "$LOCALHOST" ] && usage "Missing -h option"
-[ -z "$LOCALPORT" ] && usage "Missing -p option"
-[ -z "$LOCALUSER" ] && usage "Missing -u option"
-[ -z "$LOCALPASSWORD" ] && usage "Missing -w option"
-[ -z "$LOCALDB" ] && usage "Missing -d option"
-[ -n "$REMOTEDATAONLY" -a -n "$REMOTESCHEMAONLY" ] && usage "Either -A or -S may be specified, but not both"
-
-PGPASSWORD="$REMOTEPASSWORD" pg_dump -C $REMOTEDATAONLY $REMOTESCHEMAONLY -h $REMOTEHOST -U $REMOTEUSER $REMOTEDB |
-PGPASSWORD="$LOCALPASSWORD" psql -h $LOCALHOST -U $LOCALUSER $LOCALDB