Commit 4d4ee26c authored by Hamaker, Alec's avatar Hamaker, Alec
Browse files

transfer can successfully dump sql tables.

parent 3167378d
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -224,8 +224,6 @@ verify_source()
        read -rp "(y/n) " input
        if [ "$input" == y ]; then
            confirmed=1
            # Append the server info to the connection file
            echo "$SERVER_NAME $SERVER_IP:$SERVER_PORT:$SERVER_DB_NAME:$SERVER_USER:$SERVER_PASS" >> $CONN_FILE
        else
            warn "If the server information is incorrect, you can edit it in the following file: '$CONN_FILE'."
            warn "Exiting.."
@@ -318,6 +316,9 @@ go()
        fi
        exit 1
    fi


    # Tell the user what we are going to do..
    MSG="Preparing to"
    if [ "$PUSH" == 1 ]; then
        if [ "$TABLE" == 1 ]; then
@@ -333,6 +334,26 @@ go()
        fi
    fi
    info "$MSG"

    # psql -h "$DST_HOST" -p "$DST_PORT"\
    # -U "$DST_USR" -d "$DST_DB" -f "$SRC_TABLE".sql

    if [ "$PUSH" == 0 ]  && [ "$TABLE" == 1 ]; then # if we are pulling a table
        echo "pg_dump --host $SERVER_IP --port $SERVER_PORT --format plain --verbose --file $SOURCE_NAME.sql --table $SOURCE_NAME $SERVER_DB_NAME"

        docker run -i -e PGPASSWORD="$SERVER_PASS" postgres:alpine \
            pg_dump --host "$SERVER_IP" --port "$SERVER_PORT" -U "$SERVER_USER" -d "$SERVER_DB_NAME"\
            --verbose --table "$SOURCE_NAME" -Fp > "$SOURCE_NAME".sql

        if [ "$?" == 0 ]; then
            info "Successfully retrieved table dump for '$RED$SOURCE_NAME$NORM'"
        else
            warn "Failed to retrieve table dump for '$GREEN$SOURCE_NAME$NORM'"
        fi

    fi


}

banner