File: D:/bin/webbackup/test/webbackup.cmd
rem SS, 24/3/06 version for 1and1 server
rem SS, 10/10/08 version for new 1and1 server
rem SS, 25/09/09 improved log to add date/time and dir of FTP folder, also send today's log as email
rem SS, 20/11/09 added backup to office web server (now new BE unlimited connection)
rem SS, 01/12/09 adjusted backup to office web server from 21 to 14 days due to limited space on c drive
rem SS, 04/03/10 added backup of c:\bin, moved ftp 1and1 from first to third position, start time adjusted from 2am to 3am
:: SS, 05/05/12 changed mysql backup to backup each database to a separate .sql file, easier to restore
:: SS, 06/05/12 changed to use 7-Zip instead of WinZip, improved look for log, with '---' and date time on one line,
:: also file dates are nowin ISO format with hyphen separator (e.g. 06052012.zip becomes 2012-05-06.7z)
:: each database folder is listed and start time shown
:: SS, 07/05/12 minor improvements, separate webbak.zip and mysqldump.zip non longer created, last 7 days kept on server
:: SS, 08/05/12 moved the secure data, DNS, etc to the start after noticing it was taking 5 mins to add to zip, even though quite small in size
:: SS, 10/05/12 replaced two of the cmddate's with d:\bin\cmddate\cmddate-old to delete using old style dates
:: SS, 24/05/12 changed backups to delete from ontheworldweb.com from 31 to 65 days ago
:: SS, 26/06/12 now on new FastHosts server, removed 1and1 FTP, changed d:\backups to e:\backups, e: partition used just to hold backups, added data to path D:\MySQL Datafiles\
:: SS, 05/07/12 Windows FTP command not working, i.e. doesn't support passive transfers, changed to use WinSCP
:: SS, 12/07/12 Changed to use secure (FTPS) connection
:: SS, 15/07/12 Speed improvements, max compression done using one command to prevent creation of temp file, now using LZMA2 for all 4 threads of new Core i5. Now keeping 30 days instead of 7, zipping to t: drive (different physical drive to mysql dumps for speed and less stress)
:: SS, 16/03/13 Added a newline after the FTP because it was adding the '---..' to the same line in the log
d:
cd d:\bin\webbackup\test
:: now using WinSCP, ftpexe is the path to the app
set ftpexe=d:\bin\winscp\winscp.com
:: (SS,15/7/12) added following for one place to change the backup destination, change to e: for time being due to issue with t: drive
:: (SS,22/07/12) changed back to t:, issue with t: drive now resolved (new motherboard, i.e. chassis as Fasthosts referred to)
set bakpath=t:\backups
:: cmddate -s 0 set bakfile=%bakpath%\#.7z>>op.bat
set bakfile=t:\backups\2013-09-03.7z
rem === START OF FTP ====
:: (SS,5/7/12) for winscp, the open command specifies username and password, and we have to prefix with ftp for normal ftp (see http://winscp.net/eng/docs/scripting)
echo open sftp://backup:oscaris10@backup.itpartnership.com:22 -hostkey="8b:b8:6c:0a:c2:bf:a1:55:99:46:b9:9c:bd:43:47:7c">ftpop2.txt
:: (SS,12/7/12) replaced above with following for secure connection, certificate fingerprint is also passed
::echo open ftps://backup:oscaris10@secure.ontheworldweb.com:5821 -explicittls -certificate="59:80:cb:c7:53:c1:89:7e:ab:75:b9:3d:20:7f:10:8a:e6:61:7d:22">ftpop2.txt
::echo echo on>>ftpop2.txt
echo option batch continue>>ftpop2.txt
echo option confirm off>>ftpop2.txt
echo binary>>ftpop2.txt
rem following deletes backup file from 65 days ago, included the previous type DDMMYYYY.zip
:: (SS,5/7/12) delete replaced with rm for winscp
::cmddate -s -65 rm #.7z>>ftpop2.txt
rem following uploads todays backup file
cmddate -s 0 put %bakfile%>>ftpop2.txt
echo exit>>ftpop2.txt
rem --- FTP the file to ontheworldweb server
%ftpexe% /script=ftpop2.txt>>logtoday.txt
:: (SS,16/3/13) added following because it was added the "---.." to the same line
echo. >>logtoday.txt
rem ==== End of FTP to home ====
rem === END OF FTP ====
pause