backup solution using WAMP or windows based php/mysql server

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
dr_patso
Posts: 192
Joined: Tue May 15, 2012 3:23 am

backup solution using WAMP or windows based php/mysql server

Post by dr_patso »

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


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
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.
dr_patso
Posts: 192
Joined: Tue May 15, 2012 3:23 am

Re: backup solution using WAMP or windows based php/mysql se

Post by dr_patso »

added some new lines

if is part of active directory

Code: Select all

w32tm /resync
that line to sync time

this line to purge files 14 days or older

Code: Select all

FORFILES /p "E:\Hesk Backup\Google Drive\database" /d -14 /m *.* /c "cmd /c del @file"

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
w32tm /resync
"C:\wamp\bin\mysql\mysql5.5.16\bin\mysqldump" -u username-p"password" hesk >"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
FORFILES /p "E:\Hesk Backup\Google Drive\database" /d -14 /m *.* /c "cmd /c del @file"
Klemen
Site Admin
Posts: 10145
Joined: Fri Feb 11, 2005 4:04 pm

Re: backup solution using WAMP or windows based php/mysql se

Post by Klemen »

Thanks for sharing your backup method. It's important to keep files in a third party location (or at least a second drive) - a lesson I guess we all learn sooner or later :x :wink:
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
dr_patso
Posts: 192
Joined: Tue May 15, 2012 3:23 am

Re: backup solution using WAMP or windows based php/mysql se

Post by dr_patso »

No problem Klemen!

While testing out my restoration method, I had a scuffle with attachments, thinking i did something to completely ruin everything.. it was just my path in hesk settings. Here's my restoration method

-move all root www files to new server
-create new database with different title, i would use the same if i could (going from hesk to hostingusername_hesk)
-import the .sql file from mysqldump to this new database (click new database in phpmyadmin click import, leave default settings)
-change hesk_settings.inc.php to have correct database info and credentials

Then if attachments don't work, which is a huge possibility if you are switching providers/server platforms run through Klemens viewtopic.php?f=13&t=2604 attachments not working thread which is a sticky in this category.
Post Reply