Tweets from pichat
| Two songs from the year I created my first web sites. http://t.co/8eHrOA9K + http://t.co/AuWb2etI #video #retro About 1 day ago from pichat (Mark Seuffert) |
Tweets from 600infos
| I HAVE NYANED FOR 888.4 SECONDS! http://t.co/JQYOZebv via @nyannyancat About 1 week, 5 days ago from 600infos (Wolf) |
Trace: » FR1022 - Mini-Chat-Window » FR1015 - new shortcut topwindow [F3] » Colorscheme Talk » HTTP_USER_AGENT ändern » embedding sound » Backup a FTP Directory with wget
You are here: Pichat Wiki (en) » Snippets » Backup a FTP Directory with wget
Table of Contents
Backup a FTP Directory with wget
LINUX Bash
- backup.sh
#!/bin/sh # simple Script for Backup a FTP-Server with wget # Mark Wolfgruber 04/2010 # _ftpUSER=USENAME _ftpPASSWORD=PASSWORD _DOMAIN=domain.net _backupDIR=/backup _backupFILE=pichat-wiki_de _log=$_backupDIR/backup.log _deb=$_backupDIR/backup.debug echo "`date` ===== start backup-script, debug-file: $_deb" >> $_log echo "`date` ===== start backup-script " > $_deb # create _backupDIR if not exist [ -d $_backupDIR ] || mkdir $_backupDIR >> $_deb 2>&1 echo "`date` ===== delete old backup files " >> $_deb [ -d $_backupDIR/$_DOMAIN ] && rm -r $_backupDIR/$_DOMAIN >> $_deb 2>&1 echo "`date` ===== get new backup files " >> $_deb wget --mirror --ftp-user=$_ftpUSER --ftp-password=$_ftpPASSWORD --timestamping --tries=45 --directory-prefix=$_backupDIR ftp://$_DOMAIN/* >> $_deb 2>&1 echo "`date` ===== delete old compressed file " >> $_deb [ -f $_backupDIR/$_backupFILE.tar.gz ] && rm $_backupDIR/$_backupFILE.tar.gz >> $_deb 2>&1 echo "`date` ===== start compression " >> $_deb tar -cvzf $_backupDIR/$_backupFILE.tar.gz $_backupDIR/$_DOMAIN/$_DOMAIN >> $_deb 2>&1 echo "`date` ===== end of backup-script " >> $_deb echo "`date` ===== end of backup-script " >> $_log exit 0
Example for Windowstransfer
to get the backupFILE.tar.gz to a windows system via ssh using pscp.exe from the Putty-Tools
pscp.exe -P 22 -pw PASSWORD USER@DOMAIN.de:/backupDIR/backupFILE.tar.gz backupFILE.tar.gz >> copy.log
Windows Command
using GNU Wget 1.11.4, a non-interactive network retriever.
wget_1.11.4.zip (385.2 KiB, 1y ago, 40 downloads)
- backup.bat
@echo off set _Backup=D:\Backup\HOST set _User=USERNAME set _Pass=PASS set _Host=HOST set _Source=/ set _LogFile=%~n0.log.tail set _DebugFile=%~n0.debug.tail REM ncftpget.exe -u %_User% -p %_Pass% -R %_Host% %_Backup% %_Source% >> %_LogFile% 2>>%_DebugFile% wget.exe --mirror --ftp-user=%_User% --ftp-password=%_Pass% --timestamping --tries=45 --directory-prefix=%_Backup% ftp://%_Host%/* >> %_LogFile% 2>>%_DebugFile% <file dos backup2.bat> @echo off echo %date% %time% ### Start %~nx0 setlocal enabledelayedexpansion EnableExtensions :vars Set _User=USERNAME Set _Pass=PASSWORD Set _Host=host.domain.de Set _Port=21 set _Path=/ set _logFile=%~n0.log set _backupDir=d:\temp\www\1 if "%_Pass%"=="" set /p _Pass=Type Password for User: %_User%@%_Host%: call :CleanUp :: GNU Wget 1.8.2, a non-interactive network retriever. set _wget=C:\Programme\UnxUtils\wget.exe :: -r, --recursive recursive web-suck -- use with care! set _wget=%_wget% --recursive :: -nr, --dont-remove-listing don't remove `.listing' files. set _wget=%_wget% --dont-remove-listing :: -g, --glob=on/off turn file name globbing on or off. REM set _wget=%_wget% --glob=on :: -N, --timestamping don't re-retrieve files unless newer than local. set _wget=%_wget% --timestamping :: -o, --output-file=FILE log messages to FILE. set _wget=%_wget% --output-file=%_logFile% if not exist "%_backupDir%\." md "%_backupDir%" if not exist "%_backupDir%\." ( echo.ERROR echo.Can't create BakupDir "%_backupDir%" goto END ) cd /d "%_backupDir%" echo %_wget% ftp://%_User%:%_Pass%@%_Host%:%_Port%%_Path% pause echo.%date% %time% Backup in progess ... please wait ... %_wget% ftp://%_User%:%_Pass%@%_Host%:%_Port%%_Path% goto END ::Functions :CleanUp set _User=!_User: =! set _User=!_User:@=%%40! set _Pass=!_Pass: =%%20! set _Pass=!_Pass:@=%%40! set _Host=!_Host: =! set _Path=!_Path: =! :remove_space set _User=!_User: =! set _Host=!_Host: =! set _Path=!_Path: =! EXIT /B :clear_vars Set _User= Set _Pass= Set _Host= Set _Port= set _Path= set _logFile= set _backupDir= EXIT /B :END endlocal cd /d "%~dp0" call :clear_vars echo %date% %time% ### End %~nx0