rem ---------------------------------------------------------------------------
rem Backup web application to remote host
rem
rem $Id: remote_backup_web.bat 2007-02-07 21:24:43Z andowson $
rem ---------------------------------------------------------------------------
@echo off
rem Find out web server's IP address
ipconfig | findstr "Address" > ip1.txt
for /f "tokens=1-2 delims=:" %%i in (ip1.txt) do echo %%j > ip2.txt
for /f "tokens=1-2 delims= " %%i in (ip2.txt) do (set ip=%%i)
del ip1.txt
del ip2.txt
rem Get today's year, month, day
for /f "tokens=1-3 delims=/ " %%a in ('date /t') do (set year=%%a& set month=%%b& set day=%%c)
rem Modify the following line for your environment
set TARGET=C:\Inetpub\wwwroot\demoweb
set TARGETNAME=demoweb
set BACKUPDIR=D:\backup
set BACKUPFILE=%BACKUPDIR%\%year%\%TARGETNAME%_%ip%_%year%%month%%day%.zip
set LOGFILE=%TARGETNAME%_backup.log
echo. | date | findstr "現在日期" >> %LOGFILE%
echo. | time | findstr "現在時間" >> %LOGFILE%
rem Compress the target directory before ftp
zip -r %BACKUPFILE% %TARGET%\*
if not exist %BACKUPDIR%\%year% mkdir %BACKUPDIR%\%year%
if not exist %BACKUPFILE% goto nofile
goto ftpsession
:nofile
echo [FAILURE] can't find %BACKUPFILE% >> %LOGFILE%
echo.>> %LOGFILE%
goto end
:ftpsession
for /f "tokens=1-3 delims= " %%i in (ftp.cfg) do (set FTPSERVER=%%i&set USERNAME=%%j&set PASSWORD=%%k)
echo open %FTPSERVER% > ftpscript.txt
echo user %USERNAME% %PASSWORD% >> ftpscript.txt
echo mkdir %year%%month%%day% >> ftpscript.txt
echo cd %year%%month%%day% >> ftpscript.txt
echo bi >> ftpscript.txt
echo put %BACKUPFILE% >> ftpscript.txt
echo bye >> ftpscript.txt
echo ---=== ftp session begins ===--->> %LOGFILE%
echo ftp %BACKUPFILE% to %FTPSERVER% >> %LOGFILE%
ftp -i -n < ftpscript.txt >> %LOGFILE%
echo ---=== ftp session ends ===--->> %LOGFILE%
echo. |time | findstr "現在時間">> %LOGFILE%
echo.>> %LOGFILE%
del ftpscript.txt
set TARGET=
set TARGETNAME=
set BACKUPDIR=
set BACKUPFILE=
set LOGFILE=
set FTPSERVER=
set USERNAME=
set PASSWORD=
:end
ftp --usage
Transfers files to and from a computer running an FTP server service
(sometimes called a daemon). Ftp can be used interactively.
FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-w:windowsize] [-A] [host]
-v Suppresses display of remote server responses.
-n Suppresses auto-login upon initial connection.
-i Turns off interactive prompting during multiple file
transfers.
-d Enables debugging.
-g Disables filename globbing (see GLOB command).
-s:filename Specifies a text file containing FTP commands; the
commands will automatically run after FTP starts.
-a Use any local interface when binding data connection.
-A login as anonymous.
-w:buffersize Overrides the default transfer buffer size of 4096.
host Specifies the host name or IP address of the remote
host to connect to.
Notes:
- mget and mput commands take y/n/q for yes/no/quit.
- Use Control-C to abort commands.
remotehost username password
檔案名稱 | zip.exe |
描述 | zip.exe (v2.32) |
檔案大小 | 132 Kbytes |
下載次數 | 235 次 |
下載 |
檔案名稱 | ftp.cfg |
描述 | ftp.cfg |
檔案大小 | 28 bytes |
下載次數 | 236 次 |
下載 |
檔案名稱 | remote_backup_web.bat |
描述 | remote_backup_web.bat |
檔案大小 | 2 Kbytes |
下載次數 | 268 次 |
下載 |
7-Zip 4.57 Copyright (c) 1999-2007 Igor Pavlov 2007-12-06
Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]
[<@listfiles...>]
<Commands>
a: Add files to archive
b: Benchmark
d: Delete files from archive
e: Extract files from archive (without using directory names)
l: List contents of archive
t: Test integrity of archive
u: Update files to archive
x: eXtract files with full paths
<Switches>
-ai[r[-|0]]{@listfile|!wildcard}: Include archives
-ax[r[-|0]]{@listfile|!wildcard}: eXclude archives
-bd: Disable percentage indicator
-i[r[-|0]]{@listfile|!wildcard}: Include filenames
-m{Parameters}: set compression Method
-o{Directory}: set Output directory
-p{Password}: set Password
-r[-|0]: Recurse subdirectories
-scs{UTF-8 | WIN | DOS}: set charset for list files
-sfx[{name}]: Create SFX archive
-si[{name}]: read data from stdin
-slt: show technical information for l (List) command
-so: write data to stdout
-ssc[-]: set sensitive case mode
-ssw: compress shared files
-t{Type}: Set type of archive
-v{Size}[b|k|m|g]: Create volumes
-u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options
-w[{path}]: assign Work directory. Empty path means a temporary directory
-x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames
-y: assume Yes on all queries
7z a -psecret c:\backup.zip *
@echo off
:: 作者: namejm 出自:cn-dos
:: 求N天前的日期
:: 日期可以帶星期,但是,必須以年月日的順序排列
:: 年份必須是四位,否則會出錯
@echo off
:Main
cls
set day=%date%
set days=0
echo.&echo.
echo 當前日期是:%day%
echo.&set /p input= 請指定要追溯的天數:
setlocal enabledelayedexpansion
:: 提取日期
for /f "tokens=1-3 delims=-/. " %%i in ("%day%") do (
set /a sy=%%i, sm=100%%j %% 100, sd=100%%k %% 100
)
set /a sd-=input
if %sd% leq 0 call :count
cls&echo.&echo.
echo 當前日期是:%day%
echo.
set sm=0%sm%
set sd=0%sd%
echo %input% 天前的日期是:%sy%-%sm:~-2%-%sd:~-2%
pause>nul
goto Main
:count
set /a sm-=1
if !sm! equ 0 set /a sm=12, sy-=1
call :days
set /a sd+=days
if %sd% leq 0 goto count
goto :eof
:days
:: 獲取指定月份的總天數
set /a leap="^!(sy %% 4) & ^!(^!(sy %% 100)) | ^!(sy %% 400)"
set /a max=28+leap
for /f "tokens=%sm%" %%i in ("31 %max% 31 30 31 30 31 31 30 31 30 31") do set days=%%i
goto :eof
檔案名稱 | prevdays.bat |
描述 | 取得系統日期前N天的日期 |
檔案大小 | 988 bytes |
下載次數 | 65 次 |
下載 |
@echo off
set prevday=2009/10/04
set today=%date:~0,10%
date %prevday%
echo %date:~-3%
date %today%
@echo off
set prevday=2009/10/03
set isHoliday=0
for /f %%i in (holidays.txt) do call :checkHoliday %prevday% %%i
if %isHoliday%==1 (
echo %prevday% is a holiday
)
goto :end
:checkHoliday
if %1==%2 (
set isHoliday=1
)
:end
檔案名稱 | holidays.txt |
描述 | 假日資料檔 |
檔案大小 | 22 bytes |
下載次數 | 38 次 |
下載 |
檔案名稱 | holiday.bat |
描述 | 檢查某個日期是否為假日 |
檔案大小 | 246 bytes |
下載次數 | 40 次 |
下載 |
remotehost username