ZT: Batch application

zhaozj2021-02-16  89

Batch application

REM takes 8 bits before the system date (for short date format), if it is a long-term format (such as 2004-12-12) REM takes the top 10 (changed 8 to 10) set day =% DATE: ~ -8 % Rem takes the current complete time, will be changed to _SET CURRENTTIME =% Time :: = _% set currentTime =% CURRENTTIME: = 0% REM setting backup path set backupdir = C: / dbbackuprem Setting backup file name, format: Database name. Date. Time.dmpset filename =% backupdir% /% 2.% day%.% CURRENTTIME% .dmp

Rem @echo off

REM inspection parameter IF "% 1" == "" goto displayusageif "% 2" == "" goto displayusageif "% 3" == "" goto displayusageif "% 4" == "" Goto DisplayUsage

REM Take the top 10 set days of the system set day =% DATE: ~ -10%

REM Take the current complete time, change to _SET CURRENTTIME =% Time :: = _% set currentTime =% CURRENTTIME: = 0%

REM Setup Backup Path REM This backup directory must be manually set and created in advance. Set localbackupdir = c: / dbckupset remotebackupdir = d: / remotebackup

REM Settings Backup Server REM Setting the local log path, the log can only be stored in the local! SET defaultBackupServer = SYB_BACKUPIF "% 5" == "" (SET backupServer = SET logDir =% defaultBackupServer% SET backupDir =% localBackupDir%) ELSE (SET backupServer = at% 5 SET logDir =% 5 SET backupDir =% remoteBackupDir%)

IF not exist% logdir% mkdir% logdir%

REM Settings Backup File Name, Format: Database Service Name. Database Name. Date. Time .dmpset FileNamePrefix =% 1.% 4.% DAY%.% CURRENTTIME% Set DmpFile =% BackupDir% /% FileNamePrefix% .dmpRem temporary SQL file Name set SQLFILE =% 1.% 4. DUMP.SQLREM log file set logfile =% logdir% /% filenameprefix% .LogRem generated temporary SQL file echo dump database% 4 to 'compress :: 9 ::% dmpfile%'% backupserver %>% SQLFILE% Echo Go >>% SQLFILE% REM Backup ISQL -S% 1 -U% 2 -P% 3 -i% SQLFILE% -O% logfile% Echo backup completed, check the log file% logfile%. Goto Finished

转载请注明原文地址:https://www.9cbs.com/read-12235.html

New Post(0)