RE: Daily Backup Without Overwrite
This is probably one of the most useful batch files Ive worked on, and of course it wouldnt exist without
this group. So thanks for that.
I currently host eleven websites on Bluehost and to be on the safe site I wanted to have local backups of those
websites. But I dont really trust backups, so I wanted to have live and working duplicates of those
eleven sites on my home computer on a webserver virtual machine.
So what can this batch file do?
First it downloads the MySQL databases from Bluehost and saves them in a folder. Then it takes those
downloaded database dumps and imports them on the local database. After that, it starts downloading each
website folder placing it in wwwroot, adding to the folder name, the current day, for seven days, so that I
can go back to previous backups. It also creates log files for each website downloaded, just to make sure
there were no errors.
I run this batch file every night, so now I know that I have all my websites locally, and I know that they are
working because I can look at them through my browser and everything is working perfectly.
Its working, but I know it can be improved by more experienced people than me, so Im posting it below. Any
suggestions/modifications are welcome. And of course you can use it also.
::Create Day Variable
::------------------------------------------------------------------------
set TmpFile="%temp%.\tmp.vbs"
echo> %TmpFile% n=Now
echo>>%TmpFile% With WScript
echo>>%TmpFile% .Echo "set year=" + CStr(Year(n))
echo>>%TmpFile% .Echo "set yr=" + Right(Year(n),2)
echo>>%TmpFile% .Echo "set month="+ Right(100+Month(n),2)
echo>>%TmpFile% .Echo "set day=" + Right(100+Day(n),2)
echo>>%TmpFile% .Echo "set hour=" + Right(100+Hour(n),2)
(Continue reading)