backup solution using WAMP or windows based php/mysql server
Posted: Sun Aug 05, 2012 11:10 am
Hi Everybody,
I have come up with a fairly slick daily offsite backup solution when using WAMP, or windows based apache mysql.
Here is the batch file obviously you will replace the source and destination paths and the database username , password and database name : FYI The password is contained within quotes. EDIT: also you will need to correct the path to your mysqldump file.
copy and paste in notepad and save as .bat file. run it manually, once you find it is working you can create a scheduled task to run the batch file as often as you would like.
FYI: the xcopy is a sync, so any file that is newer, or new in the source will be overwritten in the destination path... you probably could just do this for the attachments if you aren't making any code changes, but I had 5MB to spare...
How it works for me though is I have everything exporting to a google drive folder which immediately syncs to my google drive account anytime any changes are made, probably coudl do the same with drop box, but now I have 5GBs... Once in a while I will have to manually purge the old .sql files
special note if you end up using google drive. You will want to run google drive as a service unless you are logging in every day(sad it doesn't have this option by default). Make sure google drive is working on the user account you will use to run the service (create a local if it's on a domain). Uncheck run google drive on startup in the preferences. Google how to run a program as a service with srvany or whatever.
I have come up with a fairly slick daily offsite backup solution when using WAMP, or windows based apache mysql.
Here is the batch file obviously you will replace the source and destination paths and the database username , password and database name : FYI The password is contained within quotes. EDIT: also you will need to correct the path to your mysqldump file.
copy and paste in notepad and save as .bat file. run it manually, once you find it is working you can create a scheduled task to run the batch file as often as you would like.
FYI: the xcopy is a sync, so any file that is newer, or new in the source will be overwritten in the destination path... you probably could just do this for the attachments if you aren't making any code changes, but I had 5MB to spare...
How it works for me though is I have everything exporting to a google drive folder which immediately syncs to my google drive account anytime any changes are made, probably coudl do the same with drop box, but now I have 5GBs... Once in a while I will have to manually purge the old .sql files
Code: Select all
REM @echo off
for /f "tokens=1" %%i in ('date /t') do set DATE_DOW=%%i
for /f "tokens=2" %%i in ('date /t') do set DATE_DAY=%%i
for /f %%i in ('echo %date_day:/=-%') do set DATE_DAY=%%i
for /f %%i in ('time /t') do set DATE_TIME=%%i
for /f %%i in ('echo %date_time::=-%') do set DATE_TIME=%%i
"C:\wamp\bin\mysql\mysql5.5.16\bin\mysqldump" -u username -p"password" databasename >"E:\Hesk Backup\Google Drive\database\%DATE_DAY%_%DATE_TIME%_hesk.sql"
xcopy C:\wamp\www "E:\Hesk Backup\Google Drive\website files\www" /D /E /Y