Using SDAC to backup & restore SQL Server databases

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jeremyw
Posts: 32
Joined: Thu 29 Apr 2010 17:32

Using SDAC to backup & restore SQL Server databases

Post by jeremyw » Fri 03 Jan 2014 00:55

Is this possible? If so, should I use a TMSSQL component to issue standard "BACKUP DATABASE" T-SQL statements? Is there any way to measure progress or provide feedback to the user while the database is being backed up or restored?

Thanks in advance,
Jeremy

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Using SDAC to backup & restore SQL Server databases

Post by AlexP » Fri 03 Jan 2014 11:56

Hello,

You can perform database backup in two ways. The first one is to use the BACKUP DATABASE command, for example

Code: Select all

MSConnection1.ExecSQL('BACKUP DATABASE ....');
In this case, the backup will be created using the standard SQL Server functionality. Note that you specify the path not on the local computer, but on the computer where the SQL Server is installed. When using this way, the backup progress cannot be displayed because the process is performed on the server side.
Another way is to use our TMSDump component that creates a text backup file. You can find more detailed information on this component in the MyDAC documentation: http://www.devart.com/sdac/docs/devart_sdac_tmsdump.htm . When using this component, you can use its onBackupProgress event to display the backup progress.

jeremyw
Posts: 32
Joined: Thu 29 Apr 2010 17:32

Re: Using SDAC to backup & restore SQL Server databases

Post by jeremyw » Mon 06 Jan 2014 23:41

Thank you, I appreciate the detailed response. For the first backup method, even if progress information is unavailable, is it possible to determine when the backup completes, and whether it was successful or not?

Perhaps I need to investigate the TMSDump component. Is its backup/restore speed mostly constrained by network bandwidth? Does it have any notable limitations, such as incompatibility with certain types of tables or columns? For example, how would it restore to a table with an identity field?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Using SDAC to backup & restore SQL Server databases

Post by AlexP » Thu 09 Jan 2014 14:44

Hello,

To execute the BACKUP DATABASE command, you can use the following code:

Code: Select all

  try
    MSConnection1.ExecSQL('BACKUP DATABASE ....');
    ShowMessage('Backup complete')
  except
    on E: Exception do
      ShowMessage(e.Message);
  end;
In case of successful execution, at the end of backup, a "Backup complete" message will be displayed. If errors occur during backup, a message about the occurred problems will be displayed.

When working with TMSDump, all the data are downloaded to the client, therefore the backup speed depends on both network bandwidth and the data volume. TMSDump supports all the types. To work with identity fields, TMSDump has an IdentityInsert option, that adds SET IDENTITY_INSERT on/off commands to the script for each table.

jeremyw
Posts: 32
Joined: Thu 29 Apr 2010 17:32

Re: Using SDAC to backup & restore SQL Server databases

Post by jeremyw » Tue 14 Jan 2014 02:23

Excellent, thank you again!

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Using SDAC to backup & restore SQL Server databases

Post by AlexP » Tue 14 Jan 2014 08:16

Hello,

Glad to see that the problem was solved. If you have any other questions, feel free to contact us.

Post Reply