The backup settings are available as an XML file named backup.4DSettings. 4D uses the values of this file to set the backup options (found in the Database Settings dialog box) when each backup is launched (manually, automatically, or using the BACKUP command). This file can also be used to read or set additional options, such as the amount of information stored in the backup journal, through specific XML keys. The XML keys are described in the 4D XML Keys Backup manual.
The backup.4DSettings is created by default in the "Settings" folder of the database.
Compatibility Note: The default backup.4DSettings file is named backup.xml and located in the Preferences folder in 4D versions prior to 4D v18. The file is automatically renamed and moved when the database is converted to 4D v18 or higher.
Two types of backup settings files can be used:
a default backup settings file (structure settings), used for the current database.
a user backup settings file associated to the data file. You can define a user backup settings file for each data file. This feature is designed for deployment needs by allowing you to set customized backup settings for each customer/production site.
A user backup settings file is defined for a data file when:
the "Enable User Settings in External File" security option is checked (see Using user settings)
the data file is not located in the same folder as the structure file
a folder named Settings and containing a "backup.4DSettings" file exists at the same level as the data file (see below how to create this file).
In this configuration, 4D loads and uses the contents of the "backup.4DSettings" file located in the data folder, instead of the default "backup.4DSettings" file in the database folder. This file is used for backups as well as for filling the User Settings for Data file dialog box. If one of the above conditions is not respected, 4D uses the default "backup.4DSettings" file in the Settings folder of the database.
User backup settings file(s) and the default backup settings file can exist at the same time and are used depending on the context. You can get the location of each file using the Get 4D file command:
the default backup settings file path is returned by Get 4D file(Backup settings file).
a user backup settings file path is returned by Get 4D file(Backup settings file for data).
the currently used backup settings file path is returned by Get 4D file(Current backup settings file)
It can happen that you need to edit the default backup settings file (structure settings), while a user backup settings file for the data is being used. In this case, edited settings will not be used for the current data file, but will be saved in the "backup.4DSettings" file of the database and will be used by default for any new data file. A warning message is displayed in the Settings dialog box:
To create a user backup settings file for the current data file:
Make sure the "User setting mode" is enabled (see )
Select the User Settings for Data file... option in the Design/Database Settings menu or call OPEN SETTINGS WINDOW with the User settings for data in the settingsType parameter.
Set appropriate backup options in the settings window, then click OK.
4D automatically creates the "backup.4DSettings" file in a Settings folder at the same level as the current data file.
All information regarding latest backup and restore operations are stored in the backupHistory.json file of the database. It logs the path of each saved file (including attachments) as well as number, date, time, duration, and status of each operation. To limit the size of the file, the number of logged operations is the same as the number of available backups ("Keep only the last X backup files") defined in the backup settings.
The backupHistory.json file is created in the current backup destination folder. You can get the actual path for this file using the following statement:
Warning: Deleting or moving the backupHistory.json file will cause the next backup number to be reset.
Note: The backupHistory.json file is formatted to be used by the 4D application. If you are looking for a human-readable report on backup operations, you might find the Backup journal more accurate (see below).
To make following up and verifying database backups easier, the backup module writes a summary of each operation performed in a special file, which is similar to an activity journal. Like an on-board manual, all database operations (backups, restores, log file integrations) are logged in this file whether they were scheduled or performed manually. The date and time that these operations occurred are also noted in the journal.
The backup journal is named “Backup Journal.txt” and is placed in the "Logs" folder of the database.
The backup journal can be opened with any text editor. To make parsing easier, information in the journal is separated with tabs and each line of information ends with a carriage return.
In certain backup strategies (for example, in the case where numerous attached files are being backed up), the backup journal can quickly grow to a large size. Two mechanisms can be used to control this size:
Automatic backup: Before each backup, the application examines the size of the current backup journal file. If it is greater than 10 MB, the current file is archived and a new file is created. The archived files are renamed “Backup Journal[xxx].txt”, where xxx is a number from 1 to 999. Once file number 999 is reached, the numbering begins at 1 again and the existing files will be replaced.
Possibility of reducing the amount of information recorded: To do this, simply modify the value of the VerboseMode key in the backup.4DSettings file. By default, this key is set to True. If you change the value of this key to False, only the main information will be stored in the backup journal: date and time of start of operation and any errors encountered. The XML keys concerning backup configuration are described in the 4D XML Keys Backup manual.
This file is automatically generated as soon as a log file integration with automatic repair mode has been executed by 4D. It contains the list of non-critic errors that have been repaired, if any. For more information, refer to the Automatic Restore paragraph.
The file is always generated after an automatic log file integration in auto-repair mode, whether non-critic errors were handled or not. It can also be used to detect if an automatic integration happened, for example using the following code at startup:
var $logFile : 4D.File
var $fileContent : 4D.Object $logFile:=File(Last journal integration log file) If($logFile#Null) $fileContent:=JSON Parse($logFile.getText()) If($fileContent.operations.length=0) // Send mail alerting for automatic journal integration without any error. //... Else // Send mail alerting for automatic journal integration describing issues. //... End if // Move log file to archives $logFile.moveTo($logFile.parent.folder("Archives")) End if
PROPERTIES
Product: 4D
Theme: Backup and restoring of the application