HOW TO SCHEDULE BACKUPS FOR WAMP FILES AND DATABASES
October 23, 2015 / by Marco / Categories : Technology, TIP AND TRICKS
I managed to figure out a way to backup the WAMP files and databases by using the Windows Task Scheduler and a batch file. The batch file includes using mysqldump (already part of the WAMP install), 7-zip (a free open source compression tool) and gzip (for the database compression).
Contents
BATCH FILE
Let’s have a look at the batch file:
@echo off REM ------------------------------- REM - - REM - Batch File to Backup WAMP - REM - Created By Business Legions - REM - www.businesslegions.com - REM ------------------------------- "C:\Program Files-Zipz" a -tzip c:\Backups\temp\wamp-www-backup-%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.zip C:\wamp\www C:\wamp\bin\mysql\mysql5.5.24\bin\mysqldump.exe -ubackupusername -pbackupusername123 --all-databases | C:\wamp\bin\mysql\mysql5.5.24\bin\gzip > c:\backups\temp\alldatabases-%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.sql.zip copy c:\backups\temp\*.* f:\backups\ move c:\backups\temp\*.* f:\backups\ exit
You can download the above batch script in a file from the resources section at the bottom of this post.
The first statement compresses the wamp/www folder. The name of the zip file includes the date and time by using the syntax in bold:
wamp-www-backup-%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.zip
You can actually exclude other folders from the zip file by using the statement in bold at the end of the zip compression:
"C:\Program Files-Zipz" a -tzip c:\Backups\temp\wamp-www-backup-%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.zip C:\wamp\www -xr!foldername
The next line dumps all the databases and compresses it by using gzip. You will need to download and save the gzip tool as it doesn’t actually come preinstalled with WMAP. You will also need to specify the full path of where the gzip command is located. Note that your path where mysqldump is located could be different because of the version of WAMP you’re using. When dumping the database you need to make sure you have an account with the correct permission. In the below command I used an account called backupuser with the password backupusername123. Yes – it’s not very secure having the password in a file and clear text but I use mine on a standalone environment that does not have access to the Internet so use it at your own risk.
C:\wamp\bin\mysql\mysql5.5.24\bin\mysqldump.exe -ubackupusername -pbackupusername123 --all-databases | C:\wamp\bin\mysql\mysql5.5.24\bin\gzip > c:\backups\temp\alldatabases-%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.sql.zip
The next line copies the files to an external thumb drive. That’s must a backup of a backup in case the physical hard disk drive. You can remove these lines if you think it’s overkill or alternatively you can just backup to the external thumbdrive by changing the c: to the drive of the thumb drive. In my case I
copy c:\backups\temp\*.* f:\backups\ move c:\backups\temp\*.* f:\backups\
VISUAL BASIC SCRIPT
In order to run a scheduled task silently, you need to use a Visual Basic Script. The one I have used is as per below.
Dim WinScriptHost Set WinScriptHost = CreateObject("WScript.Shell") WinScriptHost.Run Chr(34) & "D:\batch files\backups.bat" & Chr(34), 0 Set WinScriptHost = Nothing
You can download the above batch script in a file from the resources section at the bottom of this post.
Just change the path to the batch file in the script:
D:\batch files\backups.bat
WINDOWS TASK SCHEDULER
To automatically run the backup I used the task scheduler within Windows. Just create a new task:
Enter a description
Select when you want to run the task. In my case I run the backups monthly
Select the time and the months you want to run the task. I selected 11:00PM because this is a quite time where the PC is not being used.
Select the date when to run the backup. I selected the 1st of every month
Select the Action which is to Start a Program
Select the file where the Visual Basic Script is located
Click on Finish.
Your task will then be listed in the Task Scheduler Library like this.
CONCLUSION
There are a number of ways to backup WAMP, this includes using other paid Software Tools. There may be some that are FREE but I prefer to keep it simple and use batch files.
7-zip application – open source tool to backup files
GZIP tool – to compress databases. You can then use 7-zip to uncompress
WAMP – A Windows Based web server environment
Backup Batch File – Example batch file I used to run the database and file backups
Backup Visual Basic Script – Example Visual Basic File I used to run the batch file
Our Sponsors
- Advertise Me Pty Ltd
Digital Signage Solutions
OTHER ARTICLES YOU MAY LIKE

STREAMLINING PATIENT EXPERIENCE IN HEALTHCARE INDUSTRY
In our modern world, where we’ve grown accustomed to getting things instantly, the healthcare sector isn’t immune to the pressures of adapting and refining their processes. Just like any other service, healthcare centers are realizing the immense value of the patient’s journey — understanding that it directly affects their health results, trust in the system, […]
read more
THE RISE OF AUTONOMOUS VEHICLES: OPPORTUNITIES AND CHALLENGES FOR MOTOR TRADE ENTREPRENEURS
In recent years, the automotive industry has seen a dramatic transformation with the rise of both electric and autonomous vehicles. With the emergence of Tesla, a giant in the autonomous automotive market, they and the many other car brands that are now adapting more and more are paving the way for a future where driving […]
read more