home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / metabackrest.js < prev    next >
Text File  |  1997-10-25  |  3KB  |  107 lines

  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.  
  22.  
  23. // Initialize variables
  24. var ArgCount, BuName, BuVersion, BuFlags, CompObj, VersionMsg;
  25.  
  26. // Default values
  27. ArgCount = 0;
  28. BuName= "SampleBackup";
  29. BuVersion = -2;   // Use highest version number
  30. BuFlags = 0;   // RESERVED, must stay 0
  31.  
  32.  
  33.   // ** Parse Command Line
  34.  
  35.     // Loop through arguments
  36.     while (ArgCount < WScript.arguments.length)   {
  37.       
  38.       // Determine switches used
  39.       switch (WScript.arguments.item(ArgCount))   {
  40.  
  41.          case "-v":   // Designate backup version number
  42.  
  43.             // Move to next arg, which should be parameter
  44.             ++ArgCount;
  45.             if (ArgCount >= WScript.arguments.length)   
  46.                UsageMsg();
  47.             else
  48.                BuVersion = WScript.arguments.item(ArgCount);
  49.             break;
  50.            
  51.  
  52.          case "-?":
  53.          case "-h":
  54.          case "/?":
  55.             UsageMsg();
  56.             break;
  57.  
  58.          default:
  59.             if (BuName != "SampleBackup")   // Only one name allowed
  60.                UsageMsg();
  61.             else
  62.                BuName = WScript.arguments.item(ArgCount);
  63.             break;           
  64.  
  65.       }
  66.  
  67.       // Move pointer to next argument
  68.       ++ArgCount;
  69.  
  70.     }
  71.  
  72.  
  73.   // **Perform backup restore:
  74.   // First, create instance of computer object
  75.   CompObj = GetObject("IIS://Localhost");
  76.  
  77.   // Call Restore method
  78.   // NOTE:  ** All IIS services will be stopped by this method, then restarted!
  79.   WScript.echo("All services stopping ...");
  80.  
  81.   // Perform the actual Metabase backup restore
  82.   CompObj.Restore(BuName, BuVersion, BuFlags);  // NOTE: for restoration, BuFlags MUST be 0
  83.  
  84.   // Make pretty version string
  85.   if (BuVersion == -2)  
  86.         VersionMsg = "highest version";
  87.   else
  88.         VersionMsg = "version " + BuVersion;
  89.   
  90.   WScript.echo("Restored: Backup '" + BuName + "' (" + VersionMsg + ").");
  91.   WScript.echo("Services restarted.");
  92.   
  93.  
  94.  
  95.  
  96. // Display usage messsage, then QUIT
  97. function UsageMsg()  {
  98.   WScript.echo("Usage:  cscript metabackrest.js <backupname> [-v <versionnum>]");
  99.   WScript.quit();
  100. }
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.