Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.5 KiB

  1. /*********************************************
  2. *
  3. * Metabase Backup Restore Utility
  4. *
  5. **********************************************
  6. *
  7. * Description:
  8. * ------------
  9. * This sample admin script allows you to restore backups of your Metabase.
  10. *
  11. * To Run:
  12. * -------
  13. * This is the format for this script:
  14. *
  15. * cscript metabackrest.js
  16. *
  17. * NOTE: If you want to execute this script directly from Windows, use
  18. * 'wscript' instead of 'cscript'.
  19. *
  20. **********************************************/
  21. // Initialize variables
  22. var ArgCount, BuName, BuVersion, BuFlags, CompObj, VersionMsg;
  23. // Default values
  24. ArgCount = 0;
  25. BuName= "SampleBackup";
  26. BuVersion = -2; // Use highest version number
  27. BuFlags = 0; // RESERVED, must stay 0
  28. // ** Parse Command Line
  29. // Loop through arguments
  30. while (ArgCount < WScript.arguments.length) {
  31. // Determine switches used
  32. switch (WScript.arguments.item(ArgCount)) {
  33. case "-v": // Designate backup version number
  34. // Move to next arg, which should be parameter
  35. ++ArgCount;
  36. if (ArgCount >= WScript.arguments.length)
  37. UsageMsg();
  38. else
  39. BuVersion = WScript.arguments.item(ArgCount);
  40. break;
  41. case "-?":
  42. case "-h":
  43. case "/?":
  44. UsageMsg();
  45. break;
  46. default:
  47. if (BuName != "SampleBackup") // Only one name allowed
  48. UsageMsg();
  49. else
  50. BuName = WScript.arguments.item(ArgCount);
  51. break;
  52. }
  53. // Move pointer to next argument
  54. ++ArgCount;
  55. }
  56. // **Perform backup restore:
  57. // First, create instance of computer object
  58. CompObj = GetObject("IIS://Localhost");
  59. // Call Restore method
  60. // NOTE: ** All IIS services will be stopped by this method, then restarted!
  61. WScript.echo("All services stopping ...");
  62. // Perform the actual Metabase backup restore
  63. CompObj.Restore(BuName, BuVersion, BuFlags); // NOTE: for restoration, BuFlags MUST be 0
  64. // Make pretty version string
  65. if (BuVersion == -2)
  66. VersionMsg = "highest version";
  67. else
  68. VersionMsg = "version " + BuVersion;
  69. WScript.echo("Restored: Backup '" + BuName + "' (" + VersionMsg + ").");
  70. WScript.echo("Services restarted.");
  71. // Display usage messsage, then QUIT
  72. function UsageMsg() {
  73. WScript.echo("Usage: cscript metabackrest.js <backupname> [-v <versionnum>]");
  74. WScript.quit();
  75. }