Saturday, August 28, 2010

Daily backup of web projects

Bat-script for daily backup mysql


That's a thing I did today. And before that - a year ago, working in Web Studio.
It is proposed to your attention the bat-script for daily backup home-directory of your site and database (MySQL).

Requirements: Windows (in my work - 2000), the mysqldump available directly from the command line, WinRAR or any other archiver that runs from the command line.

@echo off
set DATE = `date \T`
@md "%DATE%"
cd "%DATE%"
mysqldump drupal -u root > "drupal-%DATE%.sql"
"C:\Program Files\WinRAR\rar.exe" a -inul "htdocs-%DATE%.rar" c:\apache\htdocs
cd "../"



The script can be run manually or on a schedule planner (fairly standard system scheduler). For Linux you can easily rewrite this script for your system.


When you run is generated directory-type "Mon 08/21/2010, and in it two files -" drupal-Mon 08/21/2010.sql "and" htdocs-Mon 08/21/2010.rar ". New day - new directory. The advantage of a separate directory that you can create multiple backups of different sites.

And finally - if someone knows how to change the date format on 2010/21/08 - please write.

0 Comments:

Post a Comment