ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / HFSQL / HFSQL Client/Server functions
  • Rights required to restore a backup
  • Restore operation performed from the HFSQL Control Center
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Used to restore:
  • an immediate backup (performed by HBackup or via the HFSQL Control Center).
  • a scheduled backup (described by HAddScheduledBackup or via the HFSQL Control Center).
The restored backup can be a full backup or a differential backup.
Caution: Restoring a backup should be carried out with care.
To perform this operation, you must have the rights to perform a backup (hRightsBackup) as well as the rights to lock the database (hRightsLock).
To restore the entire server (or the __jnl and __trs databases), no other application must be connected to the server. The connection used must not be attached to a database (during the call to HOpenConnection, the <Database> parameter must correspond to an empty string ("")).
To restore the databases, no connection must be established on the database to restore.
Duplicating a database A specific syntax of the HRestoreBackup function (syntax 2) allows you to restore a database backup under a different name. This allows you to perform a copy of a database by renaming it. For example: to make a copy of the MaBase28 database and rename it MaBase29, simply make a backup of MaBase28 and restore it under the name MaBase29.
New in version 2025
Restoring a backup with anonymized fields Depending on the anonymized fields management mode and the user performing the backup, data will be anonymized when restored (and will therefore be unreadable, whatever the rights of the user accessing the data). To set the storage mode for anonymized data, consult the hBackupDescription variable help.
cnxServeur is Connection

// Restauration d'une sauvegarde
IF HRestoreBackup(cnxServeur, IDSauvegarde) = False THEN
	Error("Echec de la restauration de la sauvegarde" + HErrorInfo(hErrMessage))
END
cnxServeur is Connection

// Restauration d'une sauvegarde complète et différentielle
InfoSauvegarde = HInfoBackup(cnxServeur, IDSauvegarde)
CheminSauvegarde_Diff = ExtractString(InfoSauvegarde, 4, TAB)

InfoSauvegarde = HInfoBackup(cnxServeur, IDSauvegarde_Complète)
CheminSauvegarde_Comp = ExtractString(InfoSauvegarde, 4, TAB)

IF HRestoreBackup(cnxServeur, CheminSauvegarde_Comp, CheminSauvegarde_Diff) = False THEN
	Error("Echec de la restauration de la sauvegarde" + HErrorInfo(hErrMessage))
END
Syntax

Restoring a backup from its identifier or from its path Hide the details

<Result> = HRestoreBackup(<Connection> , <Backup> [, <Progress Bar>])
<Result>: Boolean
  • True if the backup was restored,
  • False otherwise. HError is used to identify the error.
<Connection>: Character string or Connection variable
Connection to the server where the restore will be performed. This connection corresponds to:
<Backup>: Integer or character string
Can correspond to:
  • Backup identifier. This identifier can correspond to the identifier of full backup or to the identifier of differential backup.
    During an immediate backup, this identifier is returned by HBackup. This identifier can also be returned by HInfoBackup.
    In a scheduled backup, this identifier corresponds to the Identifier property of the hBackupDescription variable.
  • Path and name of backup to restore. This name was specified during the backup. This name can also be returned by HInfoBackup. If this name corresponds to a relative path, the backup will be searched for in the "Backup" subdirectory of HFSQL server. To specify the directory of Manta service, simply use "%%EXE%%".
<Progress Bar>: Optional window name, optional control name or optional integer
  • Name of the window where the progress bar will be displayed or name of the Progress Bar control.
  • Handle of the window that displays the progress bar.
WEBDEV - Server code This parameter is ignored.

Restoring a backup under a different database name Hide the details

<Result> = HRestoreBackup(<Connection> , <Backup> , <Source database> , <Destination database> [, <Progress Bar>])
<Result>: Boolean
  • True if the backup was restored,
  • False otherwise. HError is used to identify the error.
<Connection>: Character string or Connection variable
Connection to the server where the restore will be performed. This connection corresponds to:
<Backup>: Integer or character string
Can correspond to:
  • Backup identifier, returned by HBackup. This identifier can also be returned by HInfoBackup.
  • Path and name of backup to restore. This name was specified during the backup. This name can also be returned by HInfoBackup. If this name corresponds to a relative path, the backup will be searched for in the "Backup" subdirectory of HFSQL server. To specify the directory of Manta service, simply use "%%EXE%%".
<Source database>: Character string
Name of database to restore found in the backup. This syntax allows you to restore a single database found in the backup.
<Destination database>: Character string
Name of database that will be restored. This name may be different from the source database. In this case, the function allows you to make a copy of the database and rename it.
<Progress Bar>: Optional window name, optional control name or optional integer
  • Name of the window where the progress bar will be displayed or name of the Progress Bar control.
  • Handle of the window that displays the progress bar.
WEBDEV - Server code This parameter is ignored.

Restoring a differential backup found in a specific directory (available from version 15) Hide the details

<Result> = HRestoreBackup(<Connection> , <Full backup> , <Differential backup> [, <Progress Bar>])
<Result>: Boolean
  • True if the backup was restored,
  • False otherwise. HError is used to identify the error.
<Connection>: Character string or Connection variable
Connection to the server where the restore will be performed. This connection corresponds to:
<Full backup>: Character string
Path and name of the full backup to restore. This name was specified during the backup. This name can also be returned by HInfoBackup. If this name corresponds to a relative path, the backup will be searched for in the "Backup" subdirectory of HFSQL server. To specify the directory of Manta service, simply use "%%EXE%%".
<Differential backup>: Character string
Path and name of the differential backup that must be applied to the full backup. This name was specified during the backup. This name can also be returned by HInfoBackup. If this name corresponds to a relative path, the backup will be searched for in the "Backup" subdirectory of HFSQL server. To specify the directory of Manta service, simply use "%%EXE%%".
<Progress Bar>: Optional window name, optional control name or optional integer
  • Name of the window where the progress bar will be displayed or name of the Progress Bar control.
  • Handle of the window that displays the progress bar.
WEBDEV - Server code This parameter is ignored.
Remarks

Rights required to restore a backup

To restore a backup, the user or the group must have:
  • the rights to perform backups (hRightsBackup constant). These rights apply to the servers and to the databases.
  • the rights to lock the database (hRightsLock constant). These rights apply to the databases.
To find out whether these rights are granted to a user or to a group, use HInfoServerRights or HInfoDatabaseRights.
To modify the rights granted to a user or group of users, use HModifyServerRights or HModifyDatabaseRights.

Restore operation performed from the HFSQL Control Center

A backup can be restored from the HFSQL Control Center. This backup is available in the "Backups" tab of the server description.
Related Examples:
WD Duplication Training (WINDEV): WD Duplication
[ + ] This educational example explains how to duplicate a database on a server.
The duplication is performed by programming and it allows you to give a new name to the database.
The example is based on the functions for saving and restoring a HFSQL backup.
Component: wd300hf.dll
Minimum version required
  • Version 12
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help