SQL Server backup file management, and offsite backup

Source: Internet
Author: User
Tags rar


SQL Server backup file management, and offsite backup


1.sqlserver executes exec managerdb.dbo automatically. [Del_bak] Backup db


Managerdb.dbo. [Del_bak] Related scripts see the following links:

http://dwchaoyue.blog.51cto.com/2826417/1439126



2.window Automation Task D:\script\Backup.bat compressed files to the backup server


The file D:\script\Backup.bat content is as follows:

RAR a-k-r-s-m3 d:\winrardb\%date:~0,4%%date:~5,2%%date:~8,2% D:\bak

Copy D:\winrardb\%date:~0,4%%date:~5,2%%date:~8,2%.rar z:\


Note:z:\ is a network drive.


3.sqlserver Automate EXEC ManagerDB.dbo.del_historyfile Delete historical backup files


The relevant scripts for ManagerDB.dbo.del_historyfile are as follows:

DECLARE @del_date varchar (100)

Set @del_date =left (CONVERT (Nvarchar,dateadd (Dd,1,getdate ()), +) + ' T ' +convert (Nvarchar,dateadd (Hh,0,getdate ( )), 108)

EXECUTE master.dbo.xp_delete_file 0,n ' D:\bak ', N ' bak ', @del_date



4.window Automation Task D:\script\delData\Del_History_files.vbs Delete expired compressed files


The file D:\script\delData\Del_History_files.vbs content is as follows:

DIM strdate

DIM Strdatestringold

DIM strpath

DIM FS


Strdate = Date-3

Strdatestringold=year (strdate) & Right ("0" & Month (Strdate), 2) & Right ("0" & Day (Strdate), 2) & ". rar "

strpath = "D:\WinRARDB\" &strdatestringold

FS =createobject ("Scripting.FileSystemObject")


If fs.fileexists (strpath) Then

Fs. DeleteFile (strpath)

End If



Window RAR Command Reference link

Http://www.sy15168.cn/news/html/1468.html


Note:winrar cannot use RAR command directly in CMD window after installation, adding environment variable can be used directly.


This article is from the "SQL Server MySQL" blog, so be sure to keep this source http://dwchaoyue.blog.51cto.com/2826417/1535276

Related Article

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.