Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else if (isPostgre(netmasterDatabaseSource))
- {
- this.validateAdminDatabaseSource(adminDatabaseSource);
- /*
- * SET PGPASSWORD=%DB_ADMIN_PASSWORD% SET RESTORE_ARGUMENTS=-d %THIS_ENVIRONMENT_INSTANCE_NAME% -v
- * %RESTORE_FILE% %THIS_ENVIRONMENT_INSTANCE_HOME%\bin\pg_restore -h %THIS_ENVIRONMENT_SERVER_ADDRESS%
- * -p %THIS_ENVIRONMENT_SERVER_PORT% -U %DB_ADMIN_USER% %RESTORE_ARGUMENTS%
- */
- // Put logic for database instance
- command.setFile(adminDatabaseSource.getDatabaseConnectionInfo().getDatabaseInstanceHome() + "/pg_restore" + (isWindows ? ".exe" : ""));
- command.addArgument("-h"); // host
- command.addArgument(adminDatabaseSource.getDatabaseConnectionInfo().getDatabaseServerAddress()); // host
- command.addArgument("-p"); // host port
- command.addArgument(Integer.toString(adminDatabaseSource.getDatabaseConnectionInfo().getDatabaseServerPort()));
- command.addArgument("-U"); // admin username
- command.addArgument(adminDatabaseSource.getDatabaseConnectionInfo().getUserName()); // admin username
- command.addArgument("-j"); // use 4 jobs to do the restore
- command.addArgument("2");
- // options
- command.addArgument("-d"); // database instance name
- command.addArgument(netmasterDatabaseSource.getDatabaseConnectionInfo().getDatabaseInstanceName()); // database instance
- command.addArgument("-v"); // verbose messages
- command.addArgument(fileNamePath); // file to export
- // This has to be set specially as environment variable
- command.setEnvironmentVariable("PGPASSWORD", adminDatabaseSource.getDatabaseConnectionInfo().getUserPassword());
- // The result is actually printed to stderr. Therefore send everything to result.
- command.setPipeAllOutputToResult(true);
- command = shell.executeCommand(command, true);
- if (command.getExitValue() != 0)
- {
- //Some error has occured
- logger.debug("ShellCommand failed:" + command);
- throw new DatabaseTaskException("Failed to restore database " + command.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement