Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. else if (isPostgre(netmasterDatabaseSource))
  2. {
  3. this.validateAdminDatabaseSource(adminDatabaseSource);
  4.  
  5. /*
  6. * SET PGPASSWORD=%DB_ADMIN_PASSWORD% SET RESTORE_ARGUMENTS=-d %THIS_ENVIRONMENT_INSTANCE_NAME% -v
  7. * %RESTORE_FILE% %THIS_ENVIRONMENT_INSTANCE_HOME%\bin\pg_restore -h %THIS_ENVIRONMENT_SERVER_ADDRESS%
  8. * -p %THIS_ENVIRONMENT_SERVER_PORT% -U %DB_ADMIN_USER% %RESTORE_ARGUMENTS%
  9. */
  10. // Put logic for database instance
  11. command.setFile(adminDatabaseSource.getDatabaseConnectionInfo().getDatabaseInstanceHome() + "/pg_restore" + (isWindows ? ".exe" : ""));
  12. command.addArgument("-h"); // host
  13. command.addArgument(adminDatabaseSource.getDatabaseConnectionInfo().getDatabaseServerAddress()); // host
  14. command.addArgument("-p"); // host port
  15. command.addArgument(Integer.toString(adminDatabaseSource.getDatabaseConnectionInfo().getDatabaseServerPort()));
  16. command.addArgument("-U"); // admin username
  17. command.addArgument(adminDatabaseSource.getDatabaseConnectionInfo().getUserName()); // admin username
  18.  
  19. command.addArgument("-j"); // use 4 jobs to do the restore
  20. command.addArgument("2");
  21.  
  22. // options
  23. command.addArgument("-d"); // database instance name
  24. command.addArgument(netmasterDatabaseSource.getDatabaseConnectionInfo().getDatabaseInstanceName()); // database instance
  25. command.addArgument("-v"); // verbose messages
  26. command.addArgument(fileNamePath); // file to export
  27.  
  28. // This has to be set specially as environment variable
  29. command.setEnvironmentVariable("PGPASSWORD", adminDatabaseSource.getDatabaseConnectionInfo().getUserPassword());
  30.  
  31. // The result is actually printed to stderr. Therefore send everything to result.
  32. command.setPipeAllOutputToResult(true);
  33. command = shell.executeCommand(command, true);
  34. if (command.getExitValue() != 0)
  35. {
  36. //Some error has occured
  37. logger.debug("ShellCommand failed:" + command);
  38. throw new DatabaseTaskException("Failed to restore database " + command.toString());
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement