1. File backup
- File backups for NET Genium are performed using the program “FileBackup.exe”, which is located in the “Backup” directory of each NET Genium installation.
- The file backup consists of the following parts:
- backup of IIS server settings,
- backup of the NET Genium directory,
- backup of file attachments.
- While the NET Genium directory and any optional archive with additional files are always backed up in full, file attachments are backed up incrementally – only new or modified files are included.
Usage:
FileBackup.exe [target]
- The target parameter specifies the directory or network location to which the backup will be written.
- The program also supports the following optional switches:
- /iisonly – backs up IIS server settings only; in this case, the target parameter is not required (and is ignored if specified),
- /noiis – backs up the NET Genium directory and file attachments only, without IIS server settings.
- Special execution modes:
- file.ini – backs up only file attachments whose ID is greater than the value specified in the configuration file “file.ini”.
- If, in addition to backing up the NET Genium directory and file attachments, it is necessary to back up other files or directories located outside the NET Genium directory, the configuration file “FileBackup.exe.config” can be used. If the program “FileBackup.exe” finds this configuration file in the “Backup” directory before starting the backup, it creates an archive named “FileBackup.zip” in the same directory. This archive contains the files and directories defined in the configuration and is subsequently included in the NET Genium directory backup.
Example configuration file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="directory" value="C:\Services" />
<add key="excludedirectory" value="C:\Services\CRMService\POP3Downloads" />
<add key="excludefile" value="C:\Services\CRMService\*.log" />
</appSettings>
</configuration>
The configuration file allows you to specify:
- directories to be included in the backup – parameters “directory” or “includedirectory”,
- directories to be excluded from the backup – parameter “excludedirectory”,
- files to be excluded from the backup – parameter “excludefile”.
- For the “excludefile” parameter, wildcard patterns such as “*.extension” can be used to exclude all files with a given extension.
- The parameters “directory”, “includedirectory”, “excludedirectory”, and “excludefile” can be specified multiple times.
1.1. File attachment backup using the “file.ini” configuration file
- Incremental backup of NET Genium file attachments is performed by running the program “FileBackup.exe” with the configuration file name “file.ini” as the only parameter.
- If the program “FileBackup.exe” finds the file “file.ini” in the “Backup” directory, it backs up only those file attachments whose ID is greater than the value stored in this file.
- If the file “file.ini” does not exist, the program creates it and prompts the user to enter the target directory or network location and the initial file attachment ID from which the backup should start.
- After a successful backup, the value in the “file.ini” file is updated so that only newly created attachments are backed up during the next run.
1.2. Scheduling file backups
- For automatic file backups, it is recommended to create a batch file, for example “BackupFiles.bat”, and save it in the NET Genium installation directory.
- In the Windows Task Scheduler, the scheduled task must have the field “Start in (optional)” set to the “…\Backup” directory so that the program can correctly locate all required configuration files and libraries.
- If the task is run with the highest privileges, it is recommended to explicitly set the working directory in the batch file using the “cd /d” command.
Variant 1: Backup to a mapped network drive
cd /d C:\inetpub\wwwroot\NETGenium\Backup
if exist Z: goto Z_OK
net use Z: \\NAS-NETGenium\Files PASSWORD /USER:LOGIN
:Z_OK
chcp 1250
FileBackup.exe Z:
- The batch file first checks whether the network drive “Z” is mapped. If not, it maps the drive using the “net use” command.
- If access to the network location requires a user name and password, replace “LOGIN” and “PASSWORD” accordingly. If authentication is not required, the “/USER” parameter is omitted.
Variant 2: Direct backup to a network location
FileBackup.exe \\NAS-NETGenium\Files
- With this backup method, existing files are not overwritten – only newly created files are copied.
- The file “0.zip”, which contains the archive of the NET Genium directory, is overwritten on each run.
- File attachments that have been modified using the “REDUCEATTACHMENT” function are backed up again.
- In this case, the program “FileBackup.exe” can be executed directly from the Task Scheduler without using a batch file.
- Backup of file attachments is controlled by the database table “sfiles” and the column “backupdir”, which stores the path of the already performed backup. If the path specified during execution matches the value stored in the database, the file is not backed up again. This ensures incremental backup of new or modified attachments only.
- After a successful backup, a service named “BackupFiles” is logged into the database table “ng_sluzbawindows” with an interval of 1 day.
2. File backup restore
- First, create an empty directory into which NET Genium will be restored (for example “C:\inetpub\wwwroot\NETGenium”).
- Copy the program FileBackup.exe into this directory.
- Run the program with a parameter specifying the path to the backup, for example:
FileBackup.exe \\NAS-NETGenium\Files /restore
- The program restores files into the directory from which it is executed.
- During restore, existing files in the NET Genium directory are not overwritten. This allows missing files to be restored without losing newer data.
2.1. Restore all files
- This option restores the complete NET Genium directory structure from the selected backup.
- After a successful restore, the program “FileBackup.exe” can be removed from the originally empty directory. For any further restore operations, use the program located in the “Backup” directory.
2.2. Restore all files except file attachments
- Restoring the entire structure including file attachments can be time-consuming. In emergency situations, the restore process can therefore be divided into two phases:
- in the first phase, restore the NET Genium directory structure without the “Files” directory so that the application and services can be started,
- in the second phase, restore the file attachments themselves.
- After completing the first phase, the same recommendation applies as described in section 2.1.
2.3. Restore file attachments only
- Restoring file attachments separately is intended primarily as the second phase of a two-step restore after the application has been brought back online.
Restore all file attachments
- The program restores all file attachments from the backup that have not yet been restored into the “Files” directory.
Restore file attachments read from database
- For this option, the library “NETGeniumConnection.dll” must be available in the “Backup” directory. If it is not present, it can be copied from the “bin” directory.
- The program prompts the user to enter a list of database tables separated by semicolons. In these tables, columns of type “File”, “Image”, or “RichTextBox” are searched, and file attachments are restored using a “SELECT *” query.
- Due to this method of data retrieval, restoring attachments from large tables may be time-consuming.
If any of the following situations occurs, the program displays an error message and prompts the user to re-enter the input:
- the library “NETGeniumConnection.dll” is not found,
- the file “ConnectionString.txt” is not found,
- the database defined in “ConnectionString.txt” is not found,
- the database connection fails,
- the specified table is not found,
- the table does not contain any columns of type “File”, “Image”, or “RichTextBox”,
- no file attachments are found in the specified table.
After the restore is completed, statistics are displayed showing the number of attachments found, restored, and skipped.
Restore file attachments [<fromDate>] [<toDate>]
- The user specifies a date range for the creation time of file attachments. Only attachments that have not yet been restored and whose creation date falls within the specified range are restored.
- The “fromDate” and “toDate” parameters are optional and can be combined as needed.
- Date inputs may also contain NET Genium variables and functions (for example “ADDDAYS(#today#, -2)”). For this mode, the presence of the “NETGeniumConnection.dll” library in the “Backup” directory is required.
After the restore is completed, statistics are displayed showing the number of attachments found, restored, and skipped.
Restore file attachments [<fromId>] [<toId>]
- The user specifies an ID range for file attachments. Only attachments that have not yet been restored and whose ID falls within the specified range are restored.
- The “fromId” and “toId” parameters are optional and can be combined as needed.
After the restore is completed, statistics are displayed showing the number of attachments found, restored, and skipped.