備份的檔名依據年月日時分秒做為區隔 …

@echo off
title 資料備份中,請稍待一會兒(use 7zip)…

set zip_path=”C:\Program Files\7-Zip”
set dst=c:\tmp
set fscp=%systemroot%\fastcopy.exe

rem 抓取當下的年月日時分秒
set /a year=%date:~,4%
set month=%date:~5,2%
set day=%date:~8,2%
set hh=%time:~,2%
set mm=%time:~3,2%
set ss=%time:~6,2%

set mydate=%year%.%month%.%day%-%hh%.%mm%

%zip_path%\7z a -mf=BCJ2 -mx %dst%\app-%mydate%.7z @D:\backup_list.txt -scsWIN -w%dst%

if %errorlevel% == 0   goto ok  > nul
if %errorlevel% == 1   goto 11  > nul
if %errorlevel% == 2   goto 22  > nul
if %errorlevel% == 7   goto 77  > nul
if %errorlevel% == 8   goto 88  > nul
if %errorlevel% == 255 goto 255 > nul

echo 資料備份OK
%fscp% /cmd=force_copy /estimate /auto_close /bufsize=512 /speed=full %dst%\*.7z /to=\\fs1\tmp$
%fscp% /cmd=move       /estimate /auto_close /bufsize=512 /speed=full %dst%\*.7z /to=\\fs2\tmp$
goto end

echo Warning (Non fatal error(s)). For example, one or more files were locked by some other application, so they were not compressed.
goto end

echo Fatal error
goto end

echo Command line error
goto end

echo Not enough memory for operation
goto end

echo User stopped the process
goto end

@echo off

You May Have Missed