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][/decrypt][/restore]
- Optional parameters:
- /config – creates a sample configuration file “BackupServer.exe.config” in the current location,
- /decrypt – decrypts all ZIP archives in the “Files” directory; 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.
Example usage:
BackupServer.exe file.zip
1.1. Server side – creating a backup on the server
- Store the program “BackupServer.exe”, including all libraries and files, 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="C:\Firebird\DB3.FDB" />
<add key="directory" value="C:\inetpub\wwwroot" />
<add key="directory" value="C:\Services" />
<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="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 allows you to 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”,
- Firebird databases: full path to the database file,
- multiple Firebird databases in one directory: full path to the directory ending with “*.fdb”,
- directories to be backed up – parameters “directory” or “includedirectory”,
- directories excluded from backup – parameter “excludedirectory”,
- files excluded from backup – parameter “excludefile”:
- wildcard patterns such as “*.extension” can be used,
- 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,
- automatic logging of the “BackupServer” service to the “ng_sluzbawindows” table (interval 1 day) – parameter “logServiceConnectionString”.
- 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.
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”,
- databases: “database_name.bak” (MSSQL) or “database_name.fbk” (Firebird).
- 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),
- the last full backup is older than 1 month, or
- the interval defined by “fullbackupinterval” has elapsed since the last full backup.
- An incremental backup is created whenever a full backup is not performed. Incremental backups include newly created files and files with a newer modification date than previously backed-up files.
- A full backup is created if:
- Storing the full backup:
- Full backups are stored in the format “yyyy-mm-dd-x (X).zip”, where X is the ZIP file sequence number.
- If the total size of the last full backup exceeds 10 GB, the next full backup is created only on weekends.
- 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 older than 1 week (both full and incremental) are deleted.
- 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 with a maximum size of 1 GB per file,
- individual files are named “yyyy-mm-dd(X).zip”, where X is the ZIP file sequence number.
- Databases larger than 1 GB:
- if a database backup is larger than 1 GB, it is not included in a ZIP archive but stored directly in the “Files” directory as:
- “yyyy-mm-dd-database_name.bak” (MSSQL), or
- “yyyy-mm-dd-database_name.fbk” (Firebird),
- the corresponding database file is then removed from the “Temp” directory.
- if a database backup is larger than 1 GB, it is not included in a ZIP archive but stored directly in the “Files” directory as:
- Creating the files “FileList.txt” and “log.txt” in the “Files” directory:
- “FileList.txt” contains a list of all ZIP files and any database files in the “Files” directory,
- each created ZIP archive also contains a “FileList.txt” listing all backed-up paths,
- “log.txt” contains a log entry about the backup process (for example “2014-01-01 05:00:00 OK”).
- Executing programs defined by the “runfile” parameter (sequentially).
- Encrypting newly created files in the “Files” directory if “key1” and “key2” are specified in the configuration.
- Deleting backups older than 1 week (both full and incremental) 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.
- Name the virtual directory, for example, “backupserver298” and set its physical path to “C:\Services\BackupServer\Files\”.
- Configure read permissions 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.
- In the “Client” subdirectory of the “BackupServer” directory, locate the program “BackupServerService.exe”.
- Run “BackupServerService.exe” to create the shortcuts “BackupServerService – console.lnk” and “BackupServerService – user.lnk”.
- Run “BackupServerService – user.lnk” and click the “Install” button in the dialog. This installs the “BackupServerService” service, which 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 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; if not specified, downloaded backups are not decrypted),
- automatic logging of the “BackupServerService” service to the “ng_sluzbawindows” table (interval 1 day) – parameter “logServiceConnectionString”.
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.
- During each download, the age of full backups is checked. If multiple full backups are present in the “Files” directory, the first full backup and all older full backups are automatically deleted.
2. Backup restore
- A backup can be restored on a client computer by running “BackupServer.exe” with the “/restore” parameter.
- 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
- 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 RA (restore all) 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”.
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), or
- to another selected directory from which the files can later be moved as needed.
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.
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.