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:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may

man on floor with data

DevX Quick Guide to Data Ingestion

One of the biggest trends of the 21st century is the massive surge in internet usage. With major innovations such as smart technology, social media, and online shopping sites, the internet has become an essential part of everyday life for a large portion of the population. Due to this internet