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 (without the “Archive”, “Files”, “i” and “Temp” directories, without any “catalog.wci” directories and without the “*.bak” and “*.fbk” database backups and the ZIP archives other than “FileBackup.zip” (database exports by the “SqlBackup.exe” program) in the “Backup” directory, and of the “Files” directory only “Files\Files” is included) 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,
    • /no0zip – the “FileBackup.zip” and “0.zip” archives are not created. Only file attachments are backed up to the target.
Details
  • IIS server settings are saved to the “Backup” directory of the NET Genium installation and reach the backup target only as part of the “0.zip” archive – with the /no0zip switch, they are therefore not in the target. On a system other than Windows Server, IIS server settings are backed up only with the /iisonly switch.
  • If the “UnderConstruction.txt” file exists in the “Config” directory of the NET Genium installation (NET Genium is deactivated), the program backs up nothing and exits with return code 1. This also applies to the file.ini mode, but not to the /iisonly switch.
  • From the “Backup\BackupServer\Server” directory, the program does not pack the “Files”, “Temp” and “Restore” subdirectories with the backups, working files and restored backups of the “BackupServer.exe” program into the “0.zip” archive.
  • The program first builds the whole “0.zip” archive in the temporary directory of the account under which it runs, and only then copies it to the target and deletes the temporary files. The temporary directory must therefore have free space of at least the size of the “0.zip” archive including all its parts. If it does not, the backup of the “0.zip” archive ends with an error.
  • 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 following can be specified in the configuration file:

  • directories to be included in the backup – parameters “directory” or “includedirectory”,
  • individual files to be included in the backup – parameter “includefile”,
  • directories to be excluded from the backup – parameter “excludedirectory”,
  • files to be excluded from the backup – parameter “excludefile”.
    • For the “includefile” and “excludefile” parameters, the pattern “directory\*.extension” can be used, which includes or excludes all files with a given extension located directly in the specified directory. Files in its subdirectories are not affected by the pattern.
  • The parameters “directory”, “includedirectory”, “includefile”, “excludedirectory”, and “excludefile” can be specified multiple times.
  • The “FileBackup.zip” archive is created only if at least one of the “directory”, “includedirectory” or “includefile” parameters is specified in the configuration.

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 ID of the file attachment after which the backup should continue.
  • Details
    • The value in the “file.ini” file is updated continuously after each successfully backed up attachment, but only up to the first attachment that could not be backed up – its copying ended with an error or its file does not exist in the attachments directory. The next run therefore backs up the attachments from the first attachment that was not backed up, as well as newly created attachments. Images inserted into the text of a RichText control that NET Genium has moved to the database have no file in the attachments directory and count as backed up.
    • The “file.ini” file has exactly two lines – the first contains the target directory or network location of the backup, the second the ID of the file attachment after which the backup continues. The program writes the file itself. If the file has a different number of lines (for example after a manual edit with an empty line at the end), the program asks for the target and the initial ID in the same way as when the file is missing.
    • In this mode, the “FileBackup” service is not logged into the “ng_sluzbawindows” table. A successful backup is indicated only by the return code 0, with which the program ends if it backs up all attachments without an error.

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.
  • The “FileBackup.exe” program locates the NET Genium installation and the configuration files by its own location, so the “Start in (optional)” field does not need to be filled in for the program itself. A batch file, however, runs in the “C:\Windows\System32” working directory by default, so it is recommended to set the working directory explicitly in it with the “cd /d” command.
  • The target backup directory is a mandatory parameter of the “FileBackup.exe” program – without it the program prints the usage and ends with an error.

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, they are specified in place of “LOGIN” and “PASSWORD”. 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, of the file attachments, only those that have not yet been backed up to the specified target are copied, typically newly created files.
  • The file “0.zip”, which contains the archive of the NET Genium directory, is overwritten on each run. Once the archive exceeds 1 GB, further files are written to the next part (“0 (2).zip”, “0 (3).zip”...), so the parts may also be larger than 1 GB. The restore reads all parts.
  • In this case, the program “FileBackup.exe” can be executed directly from the Task Scheduler without using a batch file.
  • Details
    • File attachments that have been modified using the “REDUCEATTACHMENT” function are backed up again. An attachment file overwrites a file of the same name that already exists in the target.
    • 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.
    • Images inserted into the text of a RichText control that NET Genium has moved to the database have no file in the attachments directory. The program does not copy them, because they are part of the database backup, and marks them as backed up.
    • After the backup, a service named “FileBackup” is logged into the database table “ng_sluzbawindows” with an interval of 1 day, if the backup of the IIS server settings and of the “FileBackup.zip” and “0.zip” archives did not end with an error, and if there was no file attachment to back up or at least one was backed up. Errors of individual file attachments do not prevent the service from being logged.
    • The backup of file attachments is interrupted after 10 copy errors or after 100 attachments whose file does not exist in the attachments directory. The remaining attachments are backed up during the next run. The same limits also apply in the file.ini mode.
    • The program exits with return code 0 only if the whole backup completed without an error – a missing or uncopied file attachment results in return code 1.
    • Files and directories that cannot be read (for example locked files or directories without permissions) are left out of the “0.zip” and “FileBackup.zip” archives without any notice. This affects neither the return code nor the logging of the service.

2. File backup restore

  • First, an empty directory into which NET Genium will be restored is created (for example “C:\inetpub\wwwroot\NETGenium”).
  • The program FileBackup.exe is copied into this directory.
  • The program is run 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.
  • The “NETGeniumConnection.dll” library must be saved to the empty directory together with the “FileBackup.exe” program, for example copied from the “bin” directory of a NET Genium installation. Without it, restoring file attachments (the “Restore all files” and “Restore file attachments only” options) ends with an error, and restoring the other files stops at the first file that cannot be restored.
  • 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” and the “NETGeniumConnection.dll” library can be removed from the originally empty directory. For any further restore operations, the program located in the “Backup” directory can be used.
  • Details
    • Files and directories backed up according to the “FileBackup.exe.config” configuration file are not restored to their original location – after the restore, they are in the “FileBackup.zip” archive in the “Backup” directory of the restored NET Genium and must be extracted from it manually.

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

  • Like any other restore of file attachments, this option also requires the “NETGeniumConnection.dll” library in the directory with the program (when run from the “Backup” directory, in that 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, it searches for columns of type “File”, “Image”, or “RichTextBox” and restores the file attachments referenced by all records of these tables.
  • Due to this method of data retrieval, restoring attachments from large tables may be time-consuming.
Details

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 connection to the database defined in “ConnectionString.txt” fails.

A specified table that does not exist, does not contain any columns of type “File”, “Image”, or “RichTextBox”, or in which no file attachments are found is only reported, and the program continues with the next table. It prompts the user to re-enter the input only if it obtains no file attachment from the specified tables.

After the restore is completed, statistics are displayed showing the number of attachments found and restored and, if some attachments referenced by the records of the specified tables are missing in the backup, also their number.

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 creation date of the file in the backup directory is decisive, not the date when the attachment was created in NET Genium.
  • The “fromDate” and “toDate” parameters can be combined as needed, but at least one of them must be filled in – otherwise the program asks for both again. The “Restore all file attachments” option restores the attachments without any restriction.
  • Date inputs may also contain NET Genium variables and functions (for example “ADDDAYS(#today#, -2)”). This mode also requires the “NETGeniumConnection.dll” library in the directory with the program.

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 can be combined as needed, but at least one of them must be filled in – otherwise the program asks for both again. The “Restore all file attachments” option restores the attachments without any restriction.

After the restore is completed, statistics are displayed showing the number of attachments found, restored, and skipped.