| java.lang.Object org.continuent.sequoia.controller.backup.backupers.AbstractBackuper org.continuent.sequoia.controller.backup.backupers.AbstractPostgreSQLBackuper
All known Subclasses: org.continuent.sequoia.controller.backup.backupers.PostgreSQLTarBackuper, org.continuent.sequoia.controller.backup.backupers.PostgreSQLBinaryBackuper, org.continuent.sequoia.controller.backup.backupers.PostgreSQLSplitPlainTextBackuper, org.continuent.sequoia.controller.backup.backupers.PostgreSQLPlainTextBackuper,
AbstractPostgreSQLBackuper | abstract public class AbstractPostgreSQLBackuper extends AbstractBackuper (Code) | | This abstract class provides base methods for PostgreSQL backupers.
Currently the Backupers takes 5 parameters (all are optional):
- bindir: path to PostgreSQL binaries (if not set, the commands are
searched in the path)
- encoding: the encoding of the database that is created upon restore
- authentication: flag to use PostgreSQL authentication (default false)
- dumpServer: address of interface to offer dumps
- preRestoreScript: location of script to run before restoring
- postRestoreScript: location of script to run after restoring
- dumpTimeout: Timeout period (seconds) while performing DB dump.
- restoreTimeout: Timeout period (seconds) while performin DB restore.
- pgDumpFlags: Extra pg_dump command-line options to use while performing
DB dump.
More options can be easily added. This class makes calls to the pg_dump,
createdb, dropdb, psql and pg_restore commands.
author: Dylan Hansen author: Mathieu Peltier version: 1.1 |
Inner Class :protected class PostgreSQLUrlInfo | |
Method Summary | |
public void | deleteDump(String path, String dumpName) | protected int | executeNativeCommand(String[] stdinFeed, String[] commands) Executes a native operating system command with a standard-input feed. | protected int | executeNativeCommand(String command) Executes a native operating system command, which currently are one of: -
psql - dropdb - createdb - pg_dump - pg_restore Output of these commands is
captured and logged. | protected int | executeNativeCommand(String[] commands) Executes a native operating system command, which currently are one of:
- psql
- dropdb
- createdb
- pg_dump
- pg_restore
Output of these commands is captured and logged. | protected int | getDefaultPort() | protected String | getDumpPhysicalPath(String path, String dumpName) | protected String | getJdbcUrlPrefix() | public String | getOptions() | protected String | getPsqlCommand() | protected String | makeCommand(String command, PostgreSQLUrlInfo info, String options, String login) Creates a command string based on given info. | protected String[] | makeCommandWithAuthentication(String command, PostgreSQLUrlInfo info, String options, String login, String password, boolean isPsql) Creates a command String array used my exec(). | protected String[] | makeExpectCommandReadingStdin() Creates a expect command reading the expect-script from standard-input.
Hours of experiments has shown that the only reliable way of
programatically invoking expect with an expect-script, is via stdin or
explicit script-file. | protected String[] | makeExpectDialogueWithAuthentication(String command, PostgreSQLUrlInfo info, String options, String login, String password, int timeout) Creates an expect dialogue String array to be used as stadard input to a
"expect" command, used to pass the password parameter to the command being
run, thus allowing PostgreSQL to allow authentication. | protected String[] | makeSplitCommand(String command, PostgreSQLUrlInfo info, String options, String login) Creates a Splitted command string based on given info. | protected String[] | makeSplitCommandWithAuthentication(String command, PostgreSQLUrlInfo info, String options, String login, String password, boolean isPsql) Creates a Splitted command String array used my exec(). | protected void | printErrors() Prints contents of error output (stderr). | protected void | printOutput() Prints contents of regular output (stdout). | protected boolean | safelyExecNativeCommand(String cmd, String[] inputArray, int timeout) Execute a native command with careful logging of output and errors. | protected boolean | safelyExecNativeCommand(String[] cmds, String[] inputArray, int timeout) Execute a native command with careful logging of output and errors. | public void | setOptions(String options) |
endUserLogger | static Trace endUserLogger(Code) | | end user logger
|
postRestoreScript | protected static String postRestoreScript(Code) | | |
preRestoreScript | protected static String preRestoreScript(Code) | | |
useAuthentication | protected static boolean useAuthentication(Code) | | |
AbstractPostgreSQLBackuper | public AbstractPostgreSQLBackuper()(Code) | | Creates a new AbstractPostgreSQLBackuper object
|
executeNativeCommand | protected int executeNativeCommand(String[] stdinFeed, String[] commands) throws IOException, InterruptedException(Code) | | Executes a native operating system command with a standard-input feed. The
commands are supposed to be one of the Postgres-utilities psql - dropdb -
createdb - pg_dump - pg_restore. Output of the command is captured and
logged.
Parameters: stdinFeed - Array of input strings Parameters: commands - Array of strings (command + args) to execute 0 if successful, any number otherwise throws: IOException - throws: InterruptedException - |
executeNativeCommand | protected int executeNativeCommand(String command) throws IOException, InterruptedException(Code) | | Executes a native operating system command, which currently are one of: -
psql - dropdb - createdb - pg_dump - pg_restore Output of these commands is
captured and logged.
Parameters: command - String of command to execute 0 if successful, any number otherwise throws: IOException - throws: InterruptedException - |
executeNativeCommand | protected int executeNativeCommand(String[] commands) throws IOException, InterruptedException(Code) | | Executes a native operating system command, which currently are one of:
- psql
- dropdb
- createdb
- pg_dump
- pg_restore
Output of these commands is captured and logged.
Parameters: commands - String array of command to execute 0 if successful, any number otherwise throws: IOException - throws: InterruptedException - |
getDefaultPort | protected int getDefaultPort()(Code) | | |
getDumpPhysicalPath | protected String getDumpPhysicalPath(String path, String dumpName)(Code) | | Get the dump physical path from its logical name
Parameters: path - the path where the dump is stored Parameters: dumpName - dump logical name path to dump file |
makeCommand | protected String makeCommand(String command, PostgreSQLUrlInfo info, String options, String login)(Code) | | Creates a command string based on given info. Will append binDir if
supplied.
Parameters: command - Command to execute Parameters: info - URL info to parse and create parameters Parameters: options - Additional parameters Parameters: login - User login String containing full command to run |
makeCommandWithAuthentication | protected String[] makeCommandWithAuthentication(String command, PostgreSQLUrlInfo info, String options, String login, String password, boolean isPsql)(Code) | | Creates a command String array used my exec(). This method uses the
"expect" command to pass the password parameter to the command being run,
thus allowing PostgreSQL to allow authentication. Also uses binDir if
supplied. Note the "psql" command has different output needed by "expect"
than other commands.
Parameters: command - Command to execute Parameters: info - URL info to parse adn add parameters Parameters: options - Additional parameters Parameters: login - User login Parameters: password - User password Parameters: isPsql - Is the command being run a psql command? String array containing full command to run |
makeExpectCommandReadingStdin | protected String[] makeExpectCommandReadingStdin()(Code) | | Creates a expect command reading the expect-script from standard-input.
Hours of experiments has shown that the only reliable way of
programatically invoking expect with an expect-script, is via stdin or
explicit script-file. The expect "-c command" option simply does not work
the same way, and do cause a lot of problems.
String array containing full command to run |
makeExpectDialogueWithAuthentication | protected String[] makeExpectDialogueWithAuthentication(String command, PostgreSQLUrlInfo info, String options, String login, String password, int timeout)(Code) | | Creates an expect dialogue String array to be used as stadard input to a
"expect" command, used to pass the password parameter to the command being
run, thus allowing PostgreSQL to allow authentication. Also uses binDir if
supplied. Note that the "psql" command has different password promting than
other Postgres utilities. This expect-dialogue do a much better job at
detecting errors than the detection you get when using
makeCommandWithAuthentication() and executeNativeCommand(). Above all, it
will report failure if the PG- command never promts for a password.
Secondly, it will report failure if the invoked command exits with a
non-zero exit-status.
Parameters: command - Command to execute Parameters: info - URL info to parse adn add parameters Parameters: options - Additional parameters Parameters: login - User login Parameters: password - User password Parameters: timeout - Is the command being run a psql command? String array containing full Expect dialogue |
makeSplitCommand | protected String[] makeSplitCommand(String command, PostgreSQLUrlInfo info, String options, String login)(Code) | | Creates a Splitted command string based on given info. Will append BINDIR
if supplied.
Parameters: command - Command to execute Parameters: info - URL info to parse and create parameters Parameters: options - Additional parameters Parameters: login - User login String containing full command to run |
makeSplitCommandWithAuthentication | protected String[] makeSplitCommandWithAuthentication(String command, PostgreSQLUrlInfo info, String options, String login, String password, boolean isPsql)(Code) | | Creates a Splitted command String array used my exec(). This method uses
the "expect" command to pass the password parameter to the command being
run, thus allowing PostgreSQL to allow authentication. Also uses BINDIR if
supplied. Note the "psql" command has different output needed by "expect"
than other commands.
Parameters: command - Command to execute Parameters: info - URL info to parse adn add parameters Parameters: options - Additional parameters Parameters: login - User login Parameters: password - User password Parameters: isPsql - Is the command being run a psql command? String array containing full command to run |
printErrors | protected void printErrors()(Code) | | Prints contents of error output (stderr).
|
printOutput | protected void printOutput()(Code) | | Prints contents of regular output (stdout).
|
safelyExecNativeCommand | protected boolean safelyExecNativeCommand(String cmd, String[] inputArray, int timeout)(Code) | | Execute a native command with careful logging of output and errors.
Parameters: cmd - Command to execute Parameters: inputArray - Array of input lines Parameters: timeout - Timeout or 0 for no timeout True if command is successful |
safelyExecNativeCommand | protected boolean safelyExecNativeCommand(String[] cmds, String[] inputArray, int timeout)(Code) | | Execute a native command with careful logging of output and errors.
Parameters: cmds - Command array to execute Parameters: inputArray - Array of input lines Parameters: timeout - Timeout or 0 for no timeout True if command is successful |
|
|