หน้าเว็บ

วันเสาร์ที่ 23 กรกฎาคม พ.ศ. 2559

Bat Backup Database Axapta + Document + iXimple

Bat Backup Database Axapta + Document + iXimple
- Opent Notepad Save To .bat
- Run On Server Axapta.

Code
 
@echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a%%b)
 
 
set database_name_2015=axdb_2015
set database_name_iXimple=iXimple
 
set backup_file_2015=x:\%database_name_2015%_%mydate%_%mytime%.bak
set backup_file_iXimple=x:\%database_name_iXimple%_%mydate%_%mytime%.bak
 
set list=W1 W2 W3 W4 W5 W6 W7 W8 W9 W10 W11 W12 W13 U1 U2 U3 U4 U5 U6 public
 
OSQL -H Axapta -U sa -P sciadminsql -Q "BACKUP DATABASE %database_name_2015% TO DISK = '%backup_file_2015%'"
OSQL -H Axapta -U sa -P sciadminsql -Q "BACKUP DATABASE %database_name_iXimple% TO DISK = '%backup_file_iXimple%'"
 
IF %ERRORLEVEL% EQU 0 (
    for %%S in (%list%) do (
        echo Checking box %%S
        if exist \\192.168.2.77\%%S\ (
            echo %%S found
 
        xcopy /y %backup_file_2015% \\192.168.2.77\%%S\
        IF %ERRORLEVEL% EQU 0 del %backup_file_2015%   
 
        xcopy /y %backup_file_iXimple% \\192.168.2.77\%%S\
        IF %ERRORLEVEL% EQU 0 del %backup_file_iXimple%
 
        C:\WINDOWS\system32\ntbackup.exe backup "@C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\BackUpAxaptaFile.bks" /n "Axapta_.bkf created 9/7/2558 at 9:11" /d "Set created 9/7/2558 at 9:11" /v:yes /r:no /rs:no /hc:off /m normal /j "BackUpAxaptaFile" /l:s /f "X:\Axapta_.bkf"
        IF %ERRORLEVEL% EQU 0 xcopy /y X:\Axapta_.bkf \\192.168.2.77\%%S\
        IF %ERRORLEVEL% EQU 0 del X:\Axapta_.bkf
        GOTO :THEEND
        ) else (
            echo  %%S NOT exist
        )
    )
)
:THEEND
 
 

ไม่มีความคิดเห็น:

แสดงความคิดเห็น