Mssqlserver Database Backup statement

Source: Internet
Author: User
Mssqlserver backup statement declare @ exec_str & nbsp; varchar (60) declare @ exec_str_rar & nbsp; varchar (60) declare @ exec_str_diff & nbsp; & mssql server backup statement

Declare @ exec_str varchar (60)
Declare @ exec_str_rar varchar (60)
Declare @ exec_str_diff varchar (60)
Declare @ exec_str_rar_diff varchar (60)
Declare @ DEL_DATE_4 char (8)
Select @ DEL_DATE_4 = convert (char (8), DATEADD (dd,-4, GETDATE (), 112)
-- Process the 4-day Incremental backup of the database SZC
Select @ exec_str = 'del F: DB_BackXTOADB_FULL _ '+ @ DEL_DATE_4 +'. Bak'
Select @ exec_str_rar = 'del D: DB_Back_RARXTOADB_FULL _ '+ @ DEL_DATE_4 + '.rar'
Select @ exec_str_diff = 'del F: DB_BackdifferentXTOADB_DIFF _ '+ @ DEL_DATE_4 +' *. bak'
Select @ exec_str_rar_diff = 'del D: DB_Back_RARdifferentXTOADB_DIFF _ '+ @ DEL_DATE_4 +' *. rar'
Exec master .. xp_mongoshell @ exec_str, no_output
Exec master .. xp_mongoshell @ exec_str_rar, no_output
Exec master .. xp_mongoshell @ exec_str_diff, no_output
Exec master .. xp_mongoshell @ exec_str_rar_diff, no_output
-- Process database SZCStatistics for 4 days
Select @ exec_str = 'del F: DB_BackXTOADBStatistics '+ @ DEL_DATE_4 +'. Bak'
Select @ exec_str_rar = 'del D: DB_Back_RARXTOADBStatistics '+ @ DEL_DATE_4 + '.rar'
Exec master .. xp_mongoshell @ exec_str, no_output
Exec master .. xp_mongoshell @ exec_str_rar, no_output
-- Process database SZClog for 4 days
Select @ exec_str = 'del F: DB_BackXTOADBlog '+ @ DEL_DATE_4 +'. Bak'
Select @ exec_str_rar = 'del D: DB_Back_RARXTOADBlog '+ @ DEL_DATE_4 + '.rar'
Exec master .. xp_mongoshell @ exec_str, no_output
Exec master .. xp_mongoshell @ exec_str_rar, no_output
GO

-- 2. Step 2: Database Backup

Select 'backup Start Time: '= getdate ()
Declare @ RCL_DATE char (8)
Select @ RCL_DATE = convert (char (8), GETDATE (), 112)
Declare @ PATH varchar (60)
-- Database SZC backup -- Differential backup
Select @ PATH = 'f: DB_Back '+ 'xtoadb _ FULL _' + @ RCL_DATE + '. Bak'
Backup log xtoadb with TRUNCATE_ONLY
Backup database xtoadb to disk = @ PATH WITH INIT
-- Database SZCStatistics backup
Select @ PATH = 'f: DB_Back '+ 'xtoadbstatistics' + @ RCL_DATE + '. Bak'
-- Backup log XTOADBStatistics WITH TRUNCATE_ONLY
-- Backup database XTOADBStatistics to disk = @ PATH
-- Database SZClog backup
Select @ PATH = 'f: DB_Back '+ 'xtoadblog' + @ RCL_DATE + '. Bak'
-- Backup log XTOADBlog WITH TRUNCATE_ONLY
-- Backup database XTOADBlog to disk = @ PATH
GO?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.