1. Backup using BackupServer.exe
- Backup using the program “BackupServer.exe” is based on creating backups on the server and subsequently downloading them to a client computer over the internet or an internal network.
- Using the program “BackupServer.exe”, the following can be backed up:
- IIS server settings,
- databases (MSSQL, Firebird),
- the NET Genium directory.
- Sample program files are available in every NET Genium installation in the directory “Backup\BackupServer”.
Usage:
BackupServer.exe [/config][/task][/decrypt][/restore]
- Optional parameters:
- /config – creates a sample configuration file “BackupServer.exe.config” in the current location,
- /task – creates the scheduled task “NET Genium\BackupServer” with daily execution,
- /decrypt – decrypts all backups in the “Files” directory (ZIP archives and any older standalone “.bak” and “.fbk” files, while other files are left unchanged), see section Backup restore,
- /restore – restores files from backups stored in the “Files” directory to the target location, see section Backup restore.
- The program also supports the file parameter, which can be used to specify a particular (encrypted) file. In this case, the specified file is decrypted.
Details
- When decrypting with the /decrypt or file parameter, the program first writes the decrypted content to a temporary file in the temporary directory of the account under which it runs, and only then overwrites the encrypted file with it. The temporary directory must therefore have free space of at least the size of the decrypted file. If it does not, the decryption ends with an error.
Example usage:
BackupServer.exe file.zip
1.1. Server side – creating a backup on the server
- The program “BackupServer.exe”, including all libraries and files, is placed, for example, in the directory “C:\Services\BackupServer\”. The created backups are also stored in this directory.
- The program uses the configuration file “BackupServer.exe.config”, which contains encryption settings, a list of databases and directories to be backed up, and other options.
Example configuration file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="key1" value="abcdefgh" />
<add key="key2" value="hgfedcba" />
<add key="database" value="db1" />
<add key="database" value="(local)\SQLEXPRESS|db2" />
<add key="database" value="(local)\SQLEXPRESS|*" />
<add key="database" value="C:\Firebird\DB3.FDB" />
<add key="excludedatabase" value="(local)\SQLEXPRESS|db4" />
<add key="excludedatabase" value="C:\Firebird\Test\*.fdb" />
<add key="directory" value="C:\inetpub\wwwroot" />
<add key="directory" value="C:\Services" />
<add key="includefile" value="C:\Services\Custom\settings.json" />
<add key="excludedirectory" value="C:\Services\BackupServer\Files" />
<add key="excludedirectory" value="C:\Services\BackupServer\Temp" />
<add key="excludefile" value="C:\Services\PaymentService\*.log" />
<add key="runfile" value="C:\Services\Update\Update.exe" />
<add key="fullbackupinterval" value="7" />
<add key="multiplethreads" value="true" />
<add key="copy2directory" value="D:\BackupCopy" />
<add key="logServiceConnectionString" value="driver=firebird;datasource=localhost;user=SYSDBA;password=masterkey;database=C:\Firebird\netgenium.fdb;charset=WIN1250;collation=WIN_CZ_CI_AI" />
</appSettings>
</configuration>
The configuration file can specify:
- backup encryption – parameters “key1” and “key2” (if specified, the created files are encrypted after the backup is completed and later decrypted on the client),
- databases to be backed up – parameter “database”:
- MSSQL databases: syntax “instance_name|database_name”, where a database name specified without an instance (for example “db1”) denotes a database in the default instance “(local)”,
- all MSSQL databases on an instance: syntax “instance_name|*”,
- Firebird databases: full path to the database file,
- multiple Firebird databases in one directory: full path to the directory ending with “*.fdb”,
Details
- a Firebird database specified only by file name is looked up in “X:\Firebird\” on the same drive from which “BackupServer.exe” is running,
- the “instance_name|*” item does not back up the system databases “master”, “model”, “msdb” and “tempdb” – if the “master”, “model” or “msdb” database is to be backed up, it is listed by name (the “tempdb” database cannot be backed up),
- the “instance_name|*” item includes only the databases that are online and to which the account under which the program runs has access, and it skips the others without an error – a database that must not be left out of the backup without a warning is therefore best listed by name,
- databases excluded from backup – parameter “excludedatabase”:
- MSSQL databases are specified with the syntax “instance_name|database_name”, always including the instance name (for example “(local)|db1”),
- Firebird databases can be specified by full path or by a “*.fdb” mask,
Details
- the “excludedatabase” parameter excludes databases only from the items of the “database” parameter that contain a wildcard (“instance_name|*” and “directory\*.fdb”), whereas a database listed by name in the “database” parameter is always backed up,
- the instance name is compared as text regardless of letter case and must be written in the same way as in the item of the “database” parameter with the wildcard (for example “(local)\SQLEXPRESS|*” and “(local)\SQLEXPRESS|db4”), and a different notation of the same instance (for example “localhost” instead of “(local)”) does not match,
- directories to be backed up – parameters “directory” or “includedirectory”,
- individual files to be backed up – parameter “includefile”:
- the pattern “directory\*.extension” can also be used, which includes all files with a given extension located directly in the specified directory, without its subdirectories,
- directories excluded from backup – parameter “excludedirectory”,
- files excluded from backup – parameter “excludefile”:
- the pattern “directory\*.extension” can be used, which excludes all files with a given extension located directly in the specified directory, without its subdirectories,
- database backups by the “SqlBackup.exe” program – parameter “runsqlbackup”:
- the value is the path to the “SqlBackup.exe” program including the directory, followed by a space and the program parameters, and an item that does not contain the text “sqlbackup.exe” is not run,
- the parameter can be specified multiple times in the configuration,
Details
- the programs are run after the backup of the databases specified by the “database” parameter and before the archive is created – unless the “multiplethreads” parameter is set to “false”, they run concurrently, and the “BackupServer.exe” program waits until all of them finish,
- the programs are not run if the configuration specifies no database and no directory to back up – the “BackupServer.exe” program then ends without creating a backup,
- a backup made by the “SqlBackup.exe” program gets into the archive if the program saves it to the “Temp” directory of the “BackupServer.exe” program or to a backed-up directory – the backup target is therefore specified with a full path, and “*.bak” and “*.fbk” backups saved to a “Backup” directory do not get into the archive without the “backupall” parameter,
- backing up also the files that the program otherwise skips automatically – parameter “backupall” with the value “true” (the archive then also contains directories containing “\Logs\” and the “*.bak” and “*.fbk” backups located in a “Backup” directory),
- programs to be executed after the backup is created (but before encryption) – parameter “runfile”,
- interval for creating a full backup in days – parameter “fullbackupinterval”. If the parameter is not specified, the default interval of 1 month is used,
- parallel database backup – parameter “multiplethreads”:
- if the parameter is missing or set to “true”, databases are backed up in threads,
- the value “false” forces databases to be backed up sequentially,
- copying newly created archives to another directory – parameter “copy2directory”:
Details
- each archive is copied to the target directory with up to 10 attempts 10 seconds apart,
- the program does not delete older copies in the target directory – the deletion of backups applies only to the “Files” directory,
- automatic logging of the “BackupServer” service to the “ng_sluzbawindows” table after a successful backup – parameter “logServiceConnectionString”.
Details
- For backward compatibility, the “connectionString” parameter can also be used.
- The next run time of the service is written 1 day later than the logging time. It is shifted by another 12 hours if, according to the state of the backups before the current run, the backup of the following day would also be a full backup (typically after a full backup). Otherwise it is shifted proportionally by 1 hour per 10 GB of backups of databases larger than 1 GB.
- The logging of the service and the entry in “log.txt” are prevented by an error in any step of the program (for example a backup of a database or of the IIS server settings, starting a program from the “runfile” parameter, copying or deleting backups). They are not prevented by an error writing “FileList.txt” or by errors reading files and directories written to “Errors.txt”, not even when the whole directory specified by the “directory” or “includedirectory” parameter does not exist or is not accessible. Nor are they prevented by an error listing the directory of a “*.fdb” mask in the “excludedatabase” parameter – it is only written to “BackupServer.log”, and the backup then includes the databases that were to be excluded.
- IIS server settings are backed up automatically.
- Backups are typically triggered by a scheduled task in Windows. To create a backup, it is sufficient to run “BackupServer.exe” without parameters.
- A scheduled task can also be created using the “/task” parameter. The program creates the “NET Genium” folder in Task Scheduler, adds the “BackupServer” task, sets daily execution 5 minutes after midnight on the following day, and configures it to run with highest privileges. After creation, the task account must be changed to an account that has access to the backed-up databases and files.
Backup process
- Creation of the “Files” and “Temp” directories if they do not already exist.
- Cleaning of the “Temp” directory, which is used to temporarily store:
- backups of IIS settings (including application pools and websites),
- database backups.
- Performing the backup into the “Temp” directory:
- IIS: “applicationHost.config”,
- IIS application pools: “apppools.xml”,
- IIS websites: “sites.xml”,
- Windows scheduled tasks: “scheduledtasks.xml”,
- Indexing Service catalogs: “catalogs.IS”,
- databases: “database_name.bak” (MSSQL) or “database_name.fbk” (Firebird).
Details
- If two backed-up databases have the same name (on different instances or in different directories), the backup file of the next one gets the suffix “ (2)”, “ (3)”... and the restore extracts it under this name. The separate “yyyy-mm-dd-db-database_name.zip” archives of large databases are distinguished in the same way, for example an MSSQL and a Firebird database with the same name, or the archive of the same database from a further run on the same day.
Details
- IIS settings and Windows scheduled tasks are backed up only on Windows Server. The program first copies “%windir%\System32\inetsrv\config\applicationHost.config” to “Temp\applicationHost.config” and creates the helper file “Temp\applicationHost.bat.txt” with the command for manually restoring this file.
- If the tool “%windir%\System32\inetsrv\AppCmd.exe” exists, the program runs:
- “%windir%\System32\inetsrv\AppCmd.exe list apppool /config /xml” – the output is saved to “Temp\apppools.xml”,
- “%windir%\System32\inetsrv\AppCmd.exe list site /config /xml” – the output is saved to “Temp\sites.xml”.
- If the tool “%windir%\System32\schtasks.exe” exists, the program runs “%windir%\System32\schtasks.exe /query /xml” and saves the output to “Temp\scheduledtasks.xml”.
- The program also attempts to back up Indexing Service catalogs to “Temp\catalogs.IS”. If Indexing Service is not available on the system, this part is silently skipped.
- The files from the “Temp” directory are then included in the created ZIP archive together with the backed-up directories and files defined in the configuration. If the configuration does not contain any database or any backed-up directory, the program exits after creating the temporary server-settings backup files and no ZIP archive is created.
- Before backing up each database, the program deletes records older than 1 month from the tables “stables_stats”, “sviewpages_stats”, “squerybuilder_stats”, “sngef_stats”, and “sngscript_stats”, if those tables exist in the database.
- Database backup:
- MSSQL databases are backed up using the “BACKUP DATABASE” command with Windows authentication (“Trusted_Connection=true”),
- Firebird databases are backed up using the backup service of the Firebird database server,
Details
- before a Firebird database is backed up, “SET STATISTICS” is executed for all indexes,
- the program connects to the Firebird server on this computer through the default port 3050 with the “SYSDBA” account and the password “masterkey” – if the “SYSDBA” account has a different password or the server listens on a different port, the backup of a Firebird database does not work,
- backing up a single Firebird database has a 4-hour timeout, and after it expires, an incomplete database backup file gets into the backup (for a file over 1 GB into the separate database archive),
- databases are backed up in parallel using at most 5 threads. Before backing up a Firebird database larger than 1 GB, the program waits for the previous threads to finish.
- The “Temp” and “Files” directories of “BackupServer.exe” are excluded from backup automatically even if they are not listed in the configuration.
Details
- The “Restore” directory, which the restore of a backup creates in the program directory, is not excluded automatically. If the “BackupServer.exe” program is located in a backed-up directory, the “Restore” directory has to be deleted after the restore or excluded from the backup with the “excludedirectory” parameter.
- The program automatically skips (directories containing “\Logs\” and the “*.bak” and “*.fbk” backups in a “Backup” directory only if the “backupall” parameter is not set to “true”):
- “catalog.wci” directories,
- directories containing “\Logs\”,
- directories containing “\Temp\”,
- “*.bak” and “*.fbk” backups located in a “Backup” directory.
- Determining whether a full or incremental backup will be created:
- A full backup is created if:
- the “Files” directory is empty (no previous backups exist),
- backups exist in the “Files” directory but no full backup marked with “-x” exists,
- the full-backup interval has elapsed and the weekend restriction for large full backups is not active.
Details
- The full-backup interval is calculated from the date of the last full backup marked with “-x”:
- if “fullbackupinterval” is greater than 0, the next full backup is allowed when the new backup date is the same as or later than the last full backup date + “fullbackupinterval” days,
- if “fullbackupinterval” is missing or 0, the interval is 1 month and the next full backup is allowed when the new backup date is the same as or later than the last full backup date + 1 month.
- In this decision, the new backup date is the day before the program is run, the same as the date in the names of the backup files.
- The full-backup interval is calculated from the date of the last full backup marked with “-x”:
- If the full-backup interval has not elapsed yet, an incremental backup is created.
- If the full-backup interval has elapsed and the total size of the last full backup is up to 10 GB, a full backup is created.
- If the full-backup interval has elapsed but the total size of the last full backup exceeds 10 GB, a full backup is created only when the program is run on Saturday or Sunday. On other days, an incremental backup is created.
- An incremental backup is created whenever a full backup is not performed. Incremental backups include files with the archive attribute or files whose modification date is on or after the day following the last backup.
- A full backup is created if:
- Storing the full backup:
- Full backups are stored in the format “yyyy-mm-dd-x.zip”. If the backup is split into multiple files, the additional parts receive a sequence number according to the unique file name rules, for example “yyyy-mm-dd-x (2).zip”.
Details
- The weekend restriction for full backups larger than 10 GB is evaluated only after the full-backup interval has elapsed.
- Only the “yyyy-mm-dd-x.zip” archives and their further parts count towards the size of the last full backup, both for the weekend restriction and for the cleanup of older backups based on the free disk space. The separate “yyyy-mm-dd-db-database_name.zip” archives of large databases are not included.
- Optional cleanup of older backups:
- If a full backup is being created and at the same time:
- “fullbackupinterval” is less than 30 days, or
- (size of the last full backup × 1.5) exceeds the available disk space,
- all backups (both full and incremental) whose date in the name is 8 or more days older than the date of the new backup are deleted.
Details
- This cleanup takes place before the new full backup is created. If the creation of the new backup ends with an error, the deleted backups are not restored. If “fullbackupinterval” is 8 or more days or is missing (an interval of 1 month), they always include the last full backup.
- If a full backup is being created and at the same time:
- Creating a new backup in the “Files” directory:
- ZIP archives are created from the contents of the “Temp” directory and all directories defined in the configuration,
- the backup is split into multiple ZIP files – the next ZIP file is created as soon as the current one exceeds 1 GB, so individual ZIP files can also be larger,
- individual incremental backup files are named “yyyy-mm-dd.zip”, or “yyyy-mm-dd (2).zip”, “yyyy-mm-dd (3).zip”, and so on,
- the date in the backup name corresponds to the day before the program was run.
- Databases larger than 1 GB:
- if a database backup is larger than 1 GB, it is not included in the main ZIP archive but is stored in a separate ZIP archive in the “Files” directory as “yyyy-mm-dd-db-database_name.zip”,
- the database backup file remains in the “Temp” directory until the next run of the program, which cleans the “Temp” directory at the start. Until then, it takes up disk space.
Details
- If the configuration does not specify the “database” parameter, the “*.bak” and “*.fbk” backups in the “Temp” directory are kept during the cleanup (the “SqlBackup.exe” program from the “runsqlbackup” parameter saves them there) and take up disk space between the individual runs as well.
- Creating the files “FileList.txt” and “log.txt” in the “Files” directory:
- “FileList.txt” contains a list of all available backup files in the “Files” directory (ZIP archives and any older standalone “.bak” or “.fbk” files),
- the last ZIP file of each backup also contains the files “Directories.txt”, “Files.txt”, and “Errors.txt”,
- “Directories.txt” contains the list of directories found during backup,
- “Files.txt” contains the list of files found during backup,
- “Errors.txt” contains paths where reading or backup failed,
- “log.txt” contains an entry for every backup that finished without errors (for example “2014-01-01 05:00:00 OK”). No entry is added after a backup with errors.
Details
- The program also creates helper logs in the program directory:
- “BackupServer.log” – the main process log,
- “BackupServer-last-job.log” – the last currently running operation,
- “DriveInfo.log” – used, free, and total disk space,
- “Customer.log”, “Developer.log”, “Tester.log”, “Errors.log”, “Log.aspx.log”, “LogToDatabase.log”, “LogToDisk.log”, and “RunScript.log” – diagnostic lists derived from the backed-up NET Geniums.
- After a file has been successfully added to an archive, the program removes the archive attribute from that file if its last modification time has not changed in the meantime.
- The program deletes the “RunningQueries.htm” files in the “Logs” directories of the backed-up directories (the diagnostic output of the “RunningQueries.exe” program) during the backup.
- Executing programs defined by the “runfile” parameter:
- programs are started after the main ZIP archive is created – they are launched one by one and can then continue running in parallel,
Details
- if an item points to “Update.exe” and the current hour is later than 6, the program is not executed,
- “BackupServer.exe” waits for each executed program in turn for up to 4 hours (with more programs, the total wait can therefore be longer) and then waits 1 additional minute.
- Encrypting newly created files in the “Files” directory if “key1” and “key2” are specified in the configuration.
- If the “copy2directory” parameter is specified, newly created ZIP archives are also copied to the specified directory after creation or encryption.
- Deleting backups (both full and incremental) whose date in the name is 8 or more days older than the date of the new backup, if a full backup has just been created or if the backup date is older than the date of the last full backup.
- For the client component to function, the “Files” directory must be remotely accessible. This can be achieved by adding a virtual directory to IIS under the NET Genium application.
- On first run, the program creates a “Web.config” file in the “Files” directory. This file allows only the “HEAD” and “GET” methods for downloading backups, sets the request limit to 4 GB, and registers the “application/octet-stream” MIME type for “.bak” and “.fbk” files.
- The virtual directory is named, for example, “backupserver298”, and its physical path is set to “C:\Services\BackupServer\Files\”.
- Read permissions must be configured for this directory so that backups can be downloaded from client machines.
1.2. Client side – downloading backups to the client
- The client component is responsible for downloading backups from the server.
- The program “BackupServerService.exe” is located in the “Client” subdirectory of the “BackupServer” directory.
- When run, “BackupServerService.exe” creates the shortcuts “BackupServerService - console.lnk” and “BackupServerService - user.lnk”.
- The shortcut “BackupServerService - user.lnk” opens a dialog in which the “Install” button installs the “BackupServerService” service. The service then starts automatically after system startup.
- The service checks for available backups every 10 minutes.
- The service uses the configuration file “BackupServerService.exe.config”.
Example configuration file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="url" value="https://www.netgenium.com/backupserver298" />
<add key="smtpServer" value="localhost" />
<add key="smtpUserName" value="" />
<add key="smtpPassword" value="" />
<add key="errorFrom" value="backupserverservice@netgenium.com" />
<add key="errorTo" value="support@netgenium.com" />
<add key="key1" value="abcdefgh" />
<add key="key2" value="hgfedcba" />
<add key="logServiceConnectionString" value="driver=firebird;datasource=localhost;user=SYSDBA;password=masterkey;database=C:\Firebird\netgenium.fdb;charset=WIN1250;collation=WIN_CZ_CI_AI" />
</appSettings>
</configuration>
The configuration file must specify:
- the URL from which backups will be downloaded – parameter “url” (in the example, “backupserver298” is a virtual directory created in IIS),
- it is recommended to restrict access by IP address so that only designated client machines can access the directory,
- the “url” parameter can be specified multiple times in order to download backups from multiple servers – see the chapter “Downloading backups from multiple servers”,
- the SMTP server and credentials for sending email notifications – parameters “smtpServer”, “smtpUserName”, and “smtpPassword”,
- the sender email address for error notifications – parameter “errorFrom”,
- the recipient email address for error notifications – parameter “errorTo”,
- decryption keys for backups – optional parameters “key1” and “key2” (must match the keys on the server, and if not specified, downloaded backups are not decrypted),
- automatic logging of the “BackupServerService” service to the “ng_sluzbawindows” table – parameter “logServiceConnectionString”. If it is not specified, the “connectionString” parameter is used. For the installed service, the next run time is the start time of the iteration increased by the service interval (10 minutes). Whenever the service writes to an already existing row, it fills its “ng_restartsluzbyvpripadeporuchy” column with its own name if the column is empty, so the automatic restart of services out of operation applies to it, provided the application built on the “ng_sluzbawindows” table performs it.
Details
- The service logs itself to the “ng_sluzbawindows” table after every check, even when the server with the backups is not available or the backups are not being downloaded – it writes an unavailable “FileList.txt” list of backups only as a warning to its log. The logging therefore does not confirm that the backups are being downloaded. The service writes the download status of the individual files to the “RunningJobs.log” file in the program directory.
Downloading backups from multiple servers
- A single “BackupServerService” service can download backups from multiple servers at the same time – the “url” parameter is specified multiple times in the configuration file.
- If more than one “url” parameter is specified, each value must start with a subdirectory name separated by the “|” character, i.e. in the form “subdirectory|url”:
<add key="url" value="server1|https://www.netgenium.com/backupserver298" />
<add key="url" value="server2|https://www.anotherserver.com/backupserver310" />
- Backups from each server are downloaded into their own subdirectory of the “Files” directory – in the example above into “Files\server1\” and “Files\server2\”. The subdirectories are created automatically.
- A “url” parameter without a subdirectory name is ignored when multiple servers are specified, and the service logs this as an error. One address with a subdirectory and another one without it therefore cannot be combined.
- If only a single “url” parameter is specified, the subdirectory name is omitted and backups are downloaded directly into the “Files” directory.
- When an existing installation is switched from a single server to multiple servers, the already downloaded backups must be moved from the “Files” directory into the corresponding subdirectory – otherwise they will be downloaded again.
- The age of full backups is checked and old backups are deleted separately in each subdirectory.
- All other parameters of the configuration file are shared by all servers. Backups on all servers must therefore be encrypted with the same “key1” and “key2” keys, and error notifications from all servers are sent to the same email address.
Backup download information
- Backups are stored in the “Files” directory at the location where “BackupServerService.exe” is installed.
- If “key1” and “key2” are specified in the configuration, all ZIP archives and database files are decrypted after download.
Details
- A file that cannot be decrypted after download (except a ZIP archive that is valid even without decryption) and a ZIP archive that cannot be extracted after decryption are deleted by the service and downloaded again. On the third failure, the service sends an error notification to the address from the “errorTo” parameter and keeps the file – it is downloaded again only after it is deleted manually. Without the “key1” and “key2” parameters, the service does not check the downloaded files.
- The service first writes the decrypted content to a temporary file in the temporary directory of the account under which it runs. If that directory does not have free space of at least the size of the downloaded file, the decryption ends with an error and the service handles the file as a file that cannot be decrypted.
- During each download, the service deletes old backups that the server no longer offers in its list of available backups. If multiple full backups are present in the “Files” directory, all backups (both full and incremental) whose date in the name is on or before the day of the oldest full backup are deleted. Otherwise, backups older than 1 month and 7 days are deleted.
Details
- The deletion applies to “.zip”, “.bak” and “.fbk” files. A file whose name does not contain a readable date is deleted as soon as the server stops offering it.
2. Backup restore
- A backup can be restored on a client computer by running “BackupServer.exe” with the “/restore” parameter.
- The program restores backups from the “Files” directory in its own directory. On a client computer, it is therefore copied to the directory of “BackupServerService.exe”, into whose “Files” directory the service downloads the backups, and run from there.
Details
- The program does not go through the subdirectories of the “Files” directory during the restore. When backups are downloaded from multiple servers, the backups of one server are therefore restored from a copy of the program next to which there is a “Files” directory with the contents of the corresponding subdirectory (for example “Files\server1\”).
- If the program does not find any backup archive in the “Files” directory, it restores nothing and still writes “OK” to the “Restore.log” file.
- The program writes the final “OK” to the “Restore.log” file and ends with the return code 0 even when some archive or file could not be restored or when the check based on the “Directories.txt” and “Files.txt” files ended with an error. The result of the restore must therefore be verified by the “ERROR” lines in the “Restore.log” file.
- The program offers the following options:
- Restore all databases and server settings
- Restore all files
- Restore all files except file attachments
- Restore file attachments only
- Restore file list only (test)
- Note: If the restore is performed directly on the server, the files must first be decrypted by running “BackupServer.exe /decrypt”, because server-side backups are stored in encrypted form.
2.1. Restore all databases and server settings
- This option creates a “Restore” directory containing backups of all databases and server settings from the most recent backup.
- Database backups can then be restored in bulk using the program “SqlBackup.exe” with the restoreall option.
- IIS settings can be restored by copying the file “applicationHost.config” to the directory “Windows\System32\inetsrv\config\”. For this purpose, a batch file “applicationHost.bat.txt” is provided in the “Restore” directory.
- If the file “applicationHost.config” is not available, IIS settings can be partially restored by importing the files “sites.xml” and “apppools.xml”.
- Restored server settings can also include “scheduledtasks.xml” and “catalogs.IS” if they were created during backup.
- This option restores only archives with the newest backup date. Older incremental backups are not used for restoring databases and server settings.
- With this option, only database backups from the “Temp” directory, server settings files and the “SqlBackup.exe” and “ISBackup.exe” programs, if they are in the parts of the archive with database backups or server settings, are restored from ZIP archives. Regular application files are not restored. The “SqlBackup.exe” program restored to the “Restore” directory can be run with the restoreall option directly in it.
2.1.1. Manual restore of IIS settings
- IIS settings are restored manually from Command Prompt or PowerShell running as administrator.
- When the entire “applicationHost.config” file is restored, IIS is stopped first, the current configuration is backed up, and only then is the restored file copied to the IIS configuration directory:
iisreset /stop
copy "%windir%\System32\inetsrv\config\applicationHost.config" "%windir%\System32\inetsrv\config\applicationHost.config.before-restore"
copy "C:\Services\BackupServer\Restore\applicationHost.config" "%windir%\System32\inetsrv\config\applicationHost.config"
iisreset /start
- When only application pools and websites are restored from “apppools.xml” and “sites.xml”, the application pools are imported first and the websites afterward. Websites may reference application pools that must already exist in IIS before the websites are imported.
- Import in PowerShell:
Get-Content "C:\Services\BackupServer\Restore\apppools.xml" | & "$env:windir\System32\inetsrv\AppCmd.exe" add apppool /in
Get-Content "C:\Services\BackupServer\Restore\sites.xml" | & "$env:windir\System32\inetsrv\AppCmd.exe" add site /in
- Import in Command Prompt:
"%windir%\System32\inetsrv\AppCmd.exe" add apppool /in < "C:\Services\BackupServer\Restore\apppools.xml"
"%windir%\System32\inetsrv\AppCmd.exe" add site /in < "C:\Services\BackupServer\Restore\sites.xml"
Details
- Importing with “AppCmd.exe” adds new objects. If an application pool or website with the same name already exists in IIS, the import fails. In that case, the existing object must first be renamed or deleted, or only the missing parts of the configuration imported.
- If “BackupServer.exe” was run on a server with encrypted backups, “BackupServer.exe /decrypt” must be run first, followed by “BackupServer.exe /restore” with the Restore all databases and server settings option. This extracts “applicationHost.config”, “apppools.xml”, and “sites.xml” to the “Restore” directory.
2.2. Restore all files
- This option restores the complete directory structure, including all files, from all available backups – starting with the most recent full backup and including all subsequent incremental backups.
- The program prompts whether the directory structure should be restored to the original location (matching the server location) – existing files are overwritten. Any answer other than one starting with the letter “N”, including just pressing the Enter key, selects the restore to the original location.
- After the answer “N”, the program offers a restore to the “Restore” directory in the program directory, and after another answer “N”, it asks for a different target directory from which the files can later be moved as needed.
- When restoring all files, database backups from the “Temp” directory and the server settings files “applicationHost.config”, “applicationHost.bat.txt”, “apppools.xml”, “sites.xml”, “scheduledtasks.xml”, and “catalogs.IS” are not restored. Those belong to the “Restore all databases and server settings” option.
- After extracting the archives, the program reads “Directories.txt” and “Files.txt” from the restored backup:
- creates directories that are missing in the target location,
- writes warnings for files listed in “Files.txt” that could not be restored,
- deletes files that were extracted during restore but are not listed in the resulting “Files.txt”.
Details
- Deleting unused files is skipped if “Files.txt” does not match any restored file. This prevents unintended deletion when the file list is incomplete or incorrect.
- The warning about files that were not restored is also written for files that the program found during the backup but did not add to the archive – for example logs, excluded files or database backups in a “Backup” directory.
- The program does not delete the control files “Directories.txt”, “Files.txt”, and “Errors.txt” as unused, even though they are not listed in “Files.txt”.
2.3. Restore all files except file attachments
- Restoring all files can be time-consuming. In emergency situations, the restore process can therefore be split into two phases:
- in the first phase, restore only the directory structure without file attachments (that is, without all “Files” directories), allowing applications and services to be started,
- in the second phase, restore the file attachments themselves.
- With this option, the program skips all files stored directly in “Files” directories or in their subdirectories. The files “Directories.txt”, “Files.txt”, and “Errors.txt” are restored for the subsequent validation and remain after the restore in the “Restore” directory in the program directory, or in another directory if the restore is made into it.
- The program asks for the target location in the same way as with the “Restore all files” option.
2.4. Restore file attachments only
- Restoring file attachments separately is intended primarily as the second phase of a restore process after applications and services have been brought back online.
- When splitting the restore into two phases:
- the first phase restores the directory structure without file attachments (without “Files” directories),
- the second phase restores the file attachments.
- This option restores files in “Files” directories and their subdirectories. It also restores the control files “Directories.txt”, “Files.txt”, and “Errors.txt”.
- The program asks for the target location in the same way as with the “Restore all files” option.
2.5. Restore file list only (test)
- This option is used for a test pass through the archives without actually extracting files.
- The program writes to “Restore.log” the list of paths that would be processed during a regular restore.
- In this mode, the restore is evaluated against the original paths only logically. Files are not created or overwritten.