ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / HFSQL / HFSQL Client/Server functions
  • Rights required to perform a backup
  • Characteristics of the backup
  • Backup performed from the HFSQL Control Center
  • Scheduled backups
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Makes a backup copy of the content of an HFSQL server: all databases on the server, one or more databases, one or more data files. This backup can be performed while one or more databases are being used.
The database will be backed up at its state at the beginning of the backup: the backed up database is consistent. Some operations are not allowed during the backup: deleting the data files and the databases, updating the stored procedures.
The backup can be described using a variable of type hBackupDescription. In this case, you have the ability to define:
  • a stored procedure to run BEFORE the backup. This procedure can cancel the backup if necessary.
  • a stored procedure to run AFTER the backup.
To restore this backup, use HRestoreBackup.
To delete this backup physically, use HDeleteBackup.
Example
MyConnection is Connection
 
Backup_Doc is hBackupDescription
Backup_Doc.Description = "Doc Backup"
Backup_Doc.WithIndex = True
Backup_Doc.Destination = "Doc/Backup"
Backup_Doc.Source = "Doc/*"
Backup_Doc.ProcedureBefore = "mydatabase:DocCol.Check"
Backup_Doc.ProcedureAfter = "mydatabase:DocCol.CheckBackup"
HBackup(MyConnection, Backup_Doc)
gctConnection is Connection
 
// Back up the wdaccounts database in the "Backup" directory
IF HBackup(gctConnection, "wdaccounts/*", "wdaccounts/Backup", True, ...
"Backup " + DateSys()) = 0 THEN
Error(HErrorInfo(hErrFullDetails))
END
Syntax

Syntax that uses the hBackupDescription type (with call to stored procedures) Hide the details

<Result> = HBackup(<Connection> , <Backup definition>)
<Result>: Integer
  • Identifier of backup,
  • 0 if an error occurs. HErrorInfo is used to identify the error.
HBackup is a non-blocking function: it starts the backup and gives control back to the application.
Remark: If a stored procedure is run before the backup and if it returns False, the backup is canceled.
<Connection>: Character string or Connection variable
Connection to the server to back up. This connection corresponds to:
<Backup definition>: hBackupDescription variable
Name of the hBackupDescription variable that contains the description of the backup to perform. In this type of variable, you have the ability to define a stored procedure to run before the backup and a stored procedure to run after the backup.

Syntax kept for backward compatibility with version 12 Hide the details

<Result> = HBackup(<Connection> , <Data to back up> , <Backup destination> [, <Backup of indexes> [, <Description> [, <Progress Bar>]]])
<Result>: Integer
  • Identifier of backup,
  • 0 if an error occurs. HErrorInfo is used to identify the error.
HBackup is a non-blocking function: it starts the backup and gives control back to the application.
<Connection>: Character string or Connection variable
Connection to the server to back up. This connection corresponds to:
<Data to back up>: Character string
Filter used to describe the information to back up. The possible values are as follows:
*Backs up all server databases, logs and system databases (users, groups, rights).
Database name/*Backs up the entire database: data files, links, stored procedures, triggers.
Database name/Name file 1Backs up the <Name file 1> data file of the <Database name> database.
Name database 1/Name file 1 + TAB + Name database 2/Name file 2 + ...List of elements to back up. The separator can be the tabulation (TAB) or the semicolon (";").
SystemBacks up the system databases (users, groups, rights).
<Backup destination>: Character string
Name and destination of the backup. The backup will be preformed on the server, in a location defined by this name. If this name corresponds to a relative path, the backup will be placed in the "Backup" subdirectory of the HFSQL server. To specify:
  • the directory of the Manta service, use the "%%EXE%%" character string.
  • the year, use the "%%YEAR%%" character string (2008 for example).
  • the month on 2 digits, use the "%%MONTH%%" character string (03 for example).
  • the day, use the "%%DAY%%" character string.
  • the hour, use the "%%HOUR%%" character string.
  • the minutes, use the "%%MINUTE%%" character string.
<Backup of indexes>: Optional boolean
  • True (default) to back up the indexes,
  • False not to back them up. Not saving the indexes reduces the size of the backups. However, rebuilding the indexes will increase the restore time.
<Description>: Optional character string
Description of the backup.
<Progress Bar>: Optional control name
Name of the Progress Bar control in the window. This control is used to view the progress of the initialization step of the backup (and not the progress of the backup). This option is available in WINDEV only.
Remarks

Rights required to perform a backup

To perform 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.
To find out whether a user or a group has sufficient rights, use HInfoServerRights or HInfoDatabaseRights.
To modify the rights granted to a user or to a group of users, use HModifyServerRights or HModifyDatabaseRights.

Characteristics of the backup

The backup performed will correspond to the status of the database at the beginning of backup.
During the backup, you are not allowed to:
  • delete files and databases,
  • update the stored procedures.

Backup performed from the HFSQL Control Center

A backup can be performed from the HFSQL Control Center. This backup is available in the "Backups" tab of the server description ("New backup" button).

Scheduled backups

You have the ability to schedule the backups performed on the server:
  • via the scheduled tasks managed by WLanguage (HAddTask).
  • via the HFSQL Control Center ("Scheduled Tasks" 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.
Business / UI classification: Business Logic
Component: wd290hf.dll
Minimum version required
  • Version 12
This page is also available for…
Comments
I'll teach you how to do a backup.
Na dica de hoje..
vou ensinar como fazer um backup
no inicio do sistema

In today's tip ..
I'll teach you how to do a backup.
At the beginning of the system

En el consejo de hoy ..
Voy a enseñar cómo hacer una copia de seguridad
en el inicio del sistema

// Blog com Video e Imagen

http://windevdesenvolvimento.blogspot.com.br/2017/04/aula-1112-windev-backuprestore-001.html

http://backup%20automatico%20quando%20abrir%20sistema%20-%20windev%20backup%20001/...

De matos
07 Apr. 2017

Last update: 07/03/2023

Send a report | Local help