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).

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:

WAMP Backup Scheduled Tasks

Enter a description

WAMP Backup Scheduled Tasks Description

Select when you want to run the task. In my case I run the backups monthly

WAMP Backup Scheduled Tasks Task Trigger

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.

WAMP Backup Scheduled Tasks Task Trigger Monthly

Select the date when to run the backup. I selected the 1st of every month

WAMP Backup Scheduled Tasks Task Trigger Monthly Days

Select the Action which is to Start a Program

WAMP Backup Scheduled Tasks Action Start Program

Select the file where the Visual Basic Script is located

WAMP Backup Scheduled Tasks Program

Click on Finish.

WAMP Backup Scheduled Tasks Finish

Your task will then be listed in the Task Scheduler Library like this.

WAMP Backup Scheduled Tasks Listed

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.

RESOURCES
List of resources related to this article:

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 

 

DO YOU LIKE WHAT YOU'VE READ?
Join our subscription list and receive our content right in your mailbox. If you like to receive some Great deals our Freebies then subscribe now!

Our Sponsors

  • Follow us:

OTHER ARTICLES YOU MAY LIKE


USING BUTTERNUT.AI TO CREATE PROFESSIONAL WEBSITES

Having a professional and efficient website is crucial for any business looking to thrive online. With the constant advancements in technology, it can be overwhelming to keep up with the latest tools and platforms available for website creation. However, by leveraging the innovative capabilities of Butternut.ai, businesses can maximize their efficiency and create stunning websites […]

read more
EASY AND SIMPLE AI VIDEO EDITING SOFTWARE

EASY AND SIMPLE AI VIDEO EDITING SOFTWARE

Imagine your favourite movie scene transformed into a video in minutes, not hours. Thanks to advancements in technology, editing software has become increasingly user-friendly. Wondershare’s Filmora 14 stands as a prime example, boasting an array of AI features that simplify the editing process, with AI voice capabilities that could turn your voiceover dreams into a […]

read more

Like our Page