4D v14.3

Backing up the database

Home

 
4D v14.3
Backing up the database

Backing up the database  


 

 

A backup can be started in three ways:

  • Manually, using the Backup... command in the 4D File menu or the Backup button of the Maintenance and Security Center (MSC).
  • Automatically, using the scheduler that can be set in the Database Settings,
  • Programmatically, using the BACKUP command.

The choice will depend on your use of the database and your backup strategy. 

Note for 4D Server: A backup can be started manually from a remote machine using a method that calls the BACKUP command. The command will be executed, in all cases, on the server. 

To perform a manual backup:

  1. Select the Backup... command in the 4D File menu.
    The backup window appears:

    You can see the location of the backup folder using the pop-up menu next to the "Backup destination" area. This location is set on the Backup/Configuration page of the Database Settings.
    OR
    Select Maintenance Security Center in the Help menu of 4D and display the Backup page.
    For more information about the MSC, refer to the Maintenance and security center chapter.
    The Database properties button causes the Backup/Configuration page of the Database Settings to be displayed.
  2. Click Backup to start the backup using current parameters.

To perform a scheduled automatic backup:

  1. On the Backup/Scheduler page of the Database Settings , set the backup frequency.
    Backups are automatically performed at the times defined on this page without any type of user intervention. For more information on using this dialog box, refer to Scheduled backup settings.

To perform a scheduled backup using 4D language:

  1. Execute the BACKUP command in a method.
    The backup starts using the current parameters. You can use the On Backup Startup Database Method and On Backup Shutdown Database Method database methods for handling the backup process (see the 4D Language Reference manual).

Once the backup is started, 4D displays a dialog box with a thermometer indicating the progress of the backup:

This thermometer is also displayed on the “Backup” page of the MSC if you have used this dialog box.

The Stop button lets the user interrupt the backup at any time (refer to Encountering problems during a backup). 

The result of the last backup (successful or failed) is stored in the Last Backup Information area of the Backup page in the MSC or in the Maintenance Page of 4D Server. It is also recorded in the database Backup journal.

During a backup, access to the database is restricted by 4D according to the context. 4D locks any processes related to the types of files included in the backup: if only the structure file is being backed up, access to the structure is not possible but access to the data will be allowed. 

Conversely, if only the data file is being backed up, access to the structure is still allowed. In this case, the database access possibilities are as follows:

  • With the 4D single-user version, the database is locked for both read and write; all processes are frozen. No actions can be performed.
  • With 4D Server, the database is only write locked; client machines can view data. If a client machine sends an add, remove or change request to the server, a window appears asking the user to wait until the end of the backup.
    Once the database is saved, the window disappears and the action is performed. To cancel the request in process and not wait for the end of the backup, simply click the Cancel operation button.
    However, if the action waiting to be executed comes from a method launched prior to the backup, you should not cancel it because only operations remaining to be performed are cancelled. Also, a partially executed method can cause logical inconsistencies in the database.
    Note: When the action waiting to be executed comes from a method and the user clicks the Cancel operation button, 4D Server returns error -9976 (This command cannot be executed because the database backup is in progress).

It may happen that a backup is not executed properly. There may be several causes of a failed backup: user interruption, attached file not found, destination disk problems, incomplete transaction, etc. 4D processes the incident according to the cause. 

In all cases, the status of the last backup (successful or failed) is displayed in the Last Backup Information area of the Backup page in the MSC or in Maintenance Page of 4D Server, as well as in the Backup journal of the database. 

  • User interruption: The Stop button in the progress dialog box allows users to interrupt the backup at any time. In this case, the copying of elements is stopped and the error 1406 is generated. You can intercept this error in the On Backup Shutdown Database Method database method. 
  • Attached file not found: When an attached file cannot be found, 4D performs a partial backup (backup of database files and accessible attached files) and returns an error.
  • Backup impossible (disk is full or write-protected, missing disk, disk failure, incomplete transaction, database not launched at time of scheduled automatic backup, etc.):
    • If this is a first-time error, 4D will then make a second attempt to perform the backup. The wait between the two attempts is defined on the Backup/Backup & Restore page of the Database Settings.
    • If the second attempt fails, a system alert dialog box is displayed and an error is generated. You can intercept this error in the On Backup Shutdown Database Method.

 
PROPERTIES 

Product: 4D
Theme: Backup and restoring of the application

 
ARTICLE USAGE

4D Design Reference ( 4D v14 R2)
4D Design Reference ( 4D v12.4)
4D Design Reference ( 4D v13.4)
4D Design Reference ( 4D v14 R3)
4D Design Reference ( 4D v14.3)
4D Design Reference ( 4D v14 R4)