2009年5月8日 星期五

DISCUZ論壇每日增量備份Script

DISCUZ論壇每日增量備份Script

可以設定在工作排程中,每日將DISCUZ論壇的資料進行備份與壓縮
(For Win32版Apache/MySQL)。
以下set_all_relative_path 的部分,需要自行設定成適合你的環境喔!

Script下載點:按我下載

bak_path 備份壓縮檔要存放的路徑
wwwroot_path 你的www檔案路徑
mysqldata_path 你的mysql資料檔路徑
temp_dir_path 備份時需要用到的暫存檔路徑



@echo off
REM -----Forum Backup Script written by Jackiechin -------
REM ------------------------------------------------------
REM --------- Please Edit the Relative Path --------------
:set_all_relative_path
set bak_path=d:\forum_daily_bak
set wwwroot_path=C:\AppServ\www
set mysqldata_path=C:\AppServ\MySQL\data
set temp_dir_path=d:\temp
REM ------------------------------------------------------


:initial_all_variables
set date_str=%date%
set year_str=%date_str:~0,4%
set year_str_2digit=%year_str:~2,2%
set month_str=%date_str:~5,2%
set day_str=%date_str:~8,2%

:winrar_check
if not exist %ProgramFiles%\WinRAR\Rar.exe goto quit_this_script

:stop_web_service
START /WAIT net stop Apache2.2
START /WAIT net stop mysql

:prepare
rd %temp_dir_path%
md %temp_dir_path%
if exist %bak_path% goto backup_attachement
md %bak_path%

:backup_attachement
xcopy %wwwroot_path%\discuz\attachments\month_%year_str_2digit%%month_str%\*.* %temp_dir_path%\discuz\attachements\month_%year_str_2digit%%month_str%\ /e /y
:backup_customavatars
xcopy %wwwroot_path%\discuz\customavatars\*.* %temp_dir_path%\discuz\customavatars\ /e /y
:backup_other_stuff
xcopy %wwwroot_path%\discuz\tools\*.* %temp_dir_path%\discuz\tools\ /e /y
:backup_mysql_data
xcopy %mysqldata_path%\discuz\*.* %temp_dir_path%\mysql\data\discuz\ /e /y

:compress_temp_dir
cd "%ProgramFiles%"
cd winrar
START /WAIT winrar.exe A -M0 -R "%bak_path%\%year_str%_%month_str%_%day_str%.rar" "%temp_dir_path%\*.*"

:start service
START /WAIT net start mysql
START /WAIT net start Apache2.2

:write_log
echo Backup: %year_str%.%month_str%.%day_str% - %time% >> %bak_path%\backuplog.txt
goto exit

:quit_this_script
echo Please Install WinRAR First. Press Any Key to Quit This Script.
pause>nul

:exit
echo Backup : %year_str%.%month_str%.%day_str% - %time%
echo Logfile: %bak_path%\backuplog.txt
echo -----------Press Any Key to Quit--------------

pause>nul

0 意見:

張貼留言

留言........