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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
@echo off REM ------------------------------- REM - - REM - Batch File to Backup WAMP - REM - Created By Business Legions - REM - www.businesslegions.com - REM ------------------------------- "C:\Program Files\7-Zip\7z" 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:
1 |
wamp-www-backup-<strong>%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%</strong>.zip |
You can actually exclude other folders from the zip file by using the statement in bold at the end of the zip compression:
1 |
"C:\Program Files\7-Zip\7z" 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 <strong>-xr!foldername</strong> |
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.
1 |
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
1 2 |
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.
1 2 3 4 |
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:
1 |
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

WAMP Backup Batch Example
Backup Visual Basic Script – Example Visual Basic File I used to run the batch file

WAMP Backup Visual Basic Script
Our Sponsors
- Advertise Me Pty Ltd
Digital Signage Solutions
OTHER ARTICLES YOU MAY LIKE

HOW TO REMOVE WINDOWS 10 WELCOME SCREEN
Have you been getting the blue Windows 10 Welcome screen? It normally pops up after installing Windows 10 or after a Windows 10 update. I’ve been receiving a lot of questions relating to this and there are a few ways to remove it. One way it to change the settings in the registry setting but […]
read more
6 REASONS TO SYNCHRONIZE YOUR DATA
Technology changes and complex business requirements might compromise product data, impacting negatively on the company. Data synchronization ensures that information across the production chain is consistent. BizCaps achieves such streamlining with tools that collect data and sync it from the supplier to the consumer, increasing efficiency. Here are six reasons you require data synchronization. Increased […]
read more