Batch for System backup
花了半天做的系統備份 for windows。雖然沒有很 solid,但,堪用!
環境為 Windows 2003 server + AppServ (Apache 2 + PHP + MySQL)。另,呼叫 winrar 做壓縮備份的動作。
環境為 Windows 2003 server + AppServ (Apache 2 + PHP + MySQL)。另,呼叫 winrar 做壓縮備份的動作。
@echo off
rem echo %time%
echo Initialize...
rem
rem Variables
rem
set DB_HOST=127.0.0.1
set DB_USER=root
set DB_PASS=e1!!n
set RAR_PATH=c:\progra~1\winrar\rar
rem
rem Get date
rem
FOR /F "tokens=1-4 delims=/ " %%a IN ("%date%") DO (
SET _MyDate=%%a%%b%%c
)
rem
rem Create directory
rem
echo Create directory for backup using...
md %_MyDate%
cd %_MyDate%
rem
rem Pages compress
rem
echo Compressing all pages...
%RAR_PATH% a -r -inul eliin.rar e:\appserv\www\eliin
echo .
rem
rem Database dump
rem
echo Database dumping...
mysqldump --host=%DB_HOST% --user=%DB_USER% --password=%DB_PASS% project_mgmt \
> .\project_mgmt.sql
mysqldump --host=%DB_HOST% --user=%DB_USER% --password=%DB_PASS% eliin \
> .\eliin.sql
echo .
rem
rem configurations backup
rem
echo System configuration backup...
copy E:\AppServ\Apache2.2\conf\httpd.conf .
copy c:\winnt\php.ini .
echo .
echo Done!
rem echo %time%
rem pause
Comments
Post a Comment