Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use bat to copy the sql file with date as file name generated on the same day.

2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. Make use of the automatic backup function of SqlServer to back up the data automatically, and the file format is as follows:

Db_backup_2010_01_27_0030.bak

two。 Edit bat script

@ echo off

Echo date:~0,4%%date:~5,2%%date:~8,2%

Del h:\ backup_db* / Q

Rd / s / QH:\ backup_db

Xcopy / e d:\ backup_db\ dbbackup%date:~0,4%%date:~5,2%%date:~8,2%_00*.bak h:\ backup_db

Note:

% date:~0,4% takes the date file and takes 4 digits from bit 0, that is, the Arabic numeral of the year.

% date:~5,2% takes 2 digits back from the fifth place, that is, the month

% date:~8,2% starts at No. 8 and goes back to 2 digits, that is, the day of the month.

"*" dos wildcard, all characters of any length, but only file names or extensions; "?" The dos wildcard replaces any character, but only the file name or extension; the "*. *" global wildcard refers to any file. Del h:\ backup_db\ * / Q deletes all files under the folder. Rd / s / QH:\ backup_db delete the folder.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report