My site is ad supported.

Server Backup (Script)

Version 1.0 - Download (Requirements Included) | Download (Script Only)


Description

Server Backup is a Windows batch script which supports backup for the following:

  • IIS files and site listing
  • DNS (note - not intended for Active Directory DNS backups)
  • MySQL
  • Microsoft SQL Server
  • MailEnable
  • User specified folders

The script has the following features:

  • Resulting backup is archived to a single zip file
  • Full or incremental file backups
  • Optionally append date and time to the backup archive file name
  • Ability to pre-generate file names for additional processing once the backup is complete
  • Tested on Server 2003 and Server 2008

Requirements:

  • 7za.exe
  • SqlCmd.exe - Only required for MSSQL backups.
  • MySQL.exe - Only required for MySQL backups.
  • MySQLDump.exe - Only required for MySQL backups.
  • DNSCmd.exe - Only required for DNS backups.
  • MEBackup.exe - Only required for MailEnable backups.
  • IISWeb.vbs - Only required for Web backups on Server 2003.
  • AppCmd.exe - Only required for Web backups on Server 2008.

Examples

The following command performs a full backup of IIS (wwwroot folder + site list) files, the folder "C:\Server Scripts", all databases on the local Microsoft SQL Server instance named SQLExpress, and all databases on MySQL installation using root password "mySQLpasswd". The file will automatically have the date and time appended to the resulting file name.

ServerBackup C:\Backup.zip /D /T /Full /Web /MSSQL .\SQLExpress /MySQL mySQLpasswd /C Scripts "C:\Server Scripts"

The following script performs the sequence:

  1. Generates a file name with the current system date for an incremental backup and stores the result in a variable
  2. Runs an incremental backup of IIS, SQL Server (default instance), and MailEnable to the file name generated in step 1. The output is logged to text file using the same base as was generated in step 1.
  3. Copies the resulting backup file to a network location (so the backup will remain locally and on the network)
FOR /F "usebackq tokens=*" %%A IN (`CALL ServerBackup MyBackup /G /N /D /T /Inc`) DO SET BackupFileName=%%A
SET BackupTo=C:\Backup\%BackupFileName%
SET BackupLog=%BackupTo%_log.txt
CALL ServerBackup "%BackupTo%" /Inc /Web /MSSQL /MailEnable > "%BackupLog%"
XCOPY "%BackupTo%" "\\NetworkServer\Backups\%BackupFileName%"


My site is ad supported.

Help Information (/?)

ServerBackup Dest [/N] [/D] [/T] {/Full | /Inc} [/G] [/Web] [/DNS]
             [/MySQL RootPW] [/MSSQL [Server] [/MSSQL [Server] [...]]]
             [/MailEnable [/ConfigOnly]] [/C Name1 Dir1 [/C Name2 Dir2 [...]]]
             [/S] [/Q] [/L CmpLevel] [/V]

 Dest         Location and file name where the compressed backup file should be
              stored. The file does not need to exist, however the destination
              directory must exist. If the file exists, it will be overwritten.
              If the specified file does not end with .zip, it will be added.
 /N           If specified, appends the type of backup (Full / Inc) to end of
              the file name.
 /D           If specified, appends the current system date to end of the
              file name (Tue 07/17/2012).
 /T           If specified, appends the current system time to end of the
              file name (10:50:38.69).
 /Full        Perform a full backup (impacts only file copy backups).
              After the file has been copied, the archive bit is reset.
 /Inc         Perform an incremental backup (impacts only file copy backups).
              When in incremental mode, the file is only when the archive bit
              is set. After the file has been copied, the archive bit is reset.
 /G           Generate and output the backup file name only. Use this option if
              you need to calculate what the resulting file name will be for
              use in, for example, logging and post-backup operations.
              When this switch is provided, all backup operation specific
              parameters are ignored and only the file name is displayed.
 /Web         Specifies the IIS configuration (site listing only) and files in
              the folder C:\Inetpub\wwwroot should be backed up.
 /DNS         Specifies DNS configuration files should be backed up.
              Note: This is intended for standard primary and secondary DNS
              records and not for active directory DNS backups.
 /MySQL RootPW
              Specifies MySQL Server databases should be backed up.
              This will perform a full (dump) backup of all user databases
              The password for the user 'root' must be supplied.
 /MSSQL [Server]
              Specifies Microsoft SQL Server databases should be backed up.
              This will perform a full (simple) backup of all user databases.
              Integrated (Windows) security will be used to establish the
              connection to the MS SQL Server. Additionally, the MS SQL Server
              Service should be running as an account which allows write access
              to the executing user's temp directory (i.e. Local System).
              Optionally, the MS SQL Server to connect to can be specified.
              If omitted, the default instance on the local machine will be
              used. You can specify this switch as many times as you want to
              backup multiple instances running on the same machine.
 /MailEnable [/ConfigOnly]
              Specifies MailEnable data should be backed up. As part of the
              backup process, this utility will update the appropriate
              MailEnable registry entries used by the MEBackup tool.
              Default behavior will backup both the configuration and all post
              office messages. By specifying the optional /ConfigOnly
              switch, the post office message store will not be included in
              the backup.
 /C Name Dir  Specifies custom backup location information. You may provide as
              many custom backups as you want. The custom switch must be
              followed by a custom backup name and a respective directory.
              The Name value will be the folder name created in the zip
              archive file with the Dir being the repective folder to backup.
 /S           Suppress the configuration settings display.
 /Q           Quiet mode.
 /L CmpLevel  Specifies the compression level to use for creating the zip file.
              Valid options are: 1, 3, 5, 7, 9
              Higher number gives more compression but is slower.
              Default behavior is to use normal compression (level 5).
 /V           Verify the resulting backup archive.