Perform an MSDE database backup through Transact-SQL

Perform an MSDE database backup through Transact-SQL

The MSDE database engine is 100% compatible with SQL Server and subject to the same license policy of the Jet engine. One of the fundamental differences between MSDE and SQL Server is the lack of any graphical tool for the administration. Many users take advantage of Access 2000 as administrative front-end for the MSDE databases, but how to operate if Access isn’t avaible? For example, how to perform a fundamental operation such as the backup without the help of any external tool? In this case you can use the command line utility Osql.exe for executing the following T-SQL script (saved as BackupJob.sql) to create a new backup job and execute it through the sp_start_job stored procedure:

— Backup job creationUSE msdbEXEC sp_add_job @job_name = ‘BackupJob’,@enabled = 1,@description = ‘BackupJob’,@owner_login_name = ‘sa’,@notify_level_eventlog = 2,@notify_level_email = 2,@notify_level_netsend =2,@notify_level_page = [email protected]_email_operator_name = ‘myMailAddress’go– Data backupUSE msdbEXEC sp_add_jobstep @job_name = ‘BackupJob’,@step_name = ‘msdb database backup’,@subsystem = ‘TSQL’,@command = ‘BACKUP DATABASE msdb TO DISK = ”c:msdb.dat_bak”’,@on_success_action = 3,@retry_attempts = 5,@retry_interval = 5go– Log file backupUSE msdbEXEC sp_add_jobstep @job_name = ‘myTestBackupJob’,@step_name = ‘msdb Log backup’,@subsystem = ‘TSQL’,@command = ‘BACKUP LOG msdb TO DISK = ”c:msdb.log_bak”’,@on_success_action = 1,@retry_attempts = 5,@retry_interval = 5go– Server specificationUSE msdbEXEC sp_add_jobserver @job_name = ‘BackupJob’, @server_name = N'(local)’– Immediate job executionUSE msdbEXEC sp_start_job @job_name = ‘myTestBackupJob’This script can be launched from the command line As Follows:

OSQL -Usa -P -i BackupJob.sql -n

In case you prefer to schedule the backup procedure instead of executing it immediately, it is possible to replace the sp_start_job stored procedure with sp_add_jobschedule, whose syntax is described in the Books Online.

########################################################

This tip has been originally published on Microsoft Italia’s web site.
It has been translated and re-published on VB2TheMax with the permission of Microsoft Italia.
You can find more tips like this one (in Italian) at http://www.microsoft.com/italy/sql/articoli

########################################################

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several