Sunday, August 29, 2010

Backup - a delicate.


Backup - a delicate matter.


Virtually all agree that backups should be done. But, nevertheless, this problem pops up again and again. A recent poll showed two interesting points: First half of us are not doing backups at all, and secondly the author does not even occurred to me to include in the survey item "once a day. What is wrong with a simple, at first glance, the task - to pack their files and put the archive into a warm and dry place?



The main problem is that Bacup not apply to those things that you can do without thinking! If you try to blunt wrap up the entire contents of the screw, then first you have nowhere to these files (daily:)) hold, and secondly your machine will do archiving clock itself, the beloved, instead of carrying out your tasks. And when you start to think (which is already not easy), it turns out that the data on the HDD very different, and Bacup them desirable, too, in different ways (that definitely complicates the situation). As a consequence, any decision not to do backups at all (disguised as a "set aside for later"), or put to the first available tool and somehow managed to quickly set up, in the hope that this will be enough.

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.

Friday, August 27, 2010

Mysqldump in csv format

Pull data from mysql table in a simple CSV


Okay - there is a task to pull data from mysql table in a simple csv file to open it quickly to excel. Why do people need such magic - I will never understand, but once the customer has asked, I did.
So, give in to the power of the console and write:
mysqldump -u [USER_NAME] -p "--where=[WHERE]" "--fields-terminated-by=," "--tab=./" [DB_NAME] [TABLE] > [TABLE].txt


So much love (at the output we get two files - one with SQL and the second with CSV)
p.s. directory that runs this command must be open for entries, otherwise it will curse;)

Monday, August 9, 2010

How To: Setup Daily MySQL Backup on Win

How To: Setup Daily MySQL Backup on Windows

Protecting information in databases and possibility to restore databases in case of need is the highest priority task in many companies. But not all DBMSs have built-in tools for data protection (tools to backup and restore databases). And MySQL is one of such DBMSs.
Making database backups is one of the most important things in the process of administrating MySQL databases, because some critical data loss can be irreplaceable.
The task of making daily mysql backup can be solved with the help of the backup database function of dbForge Studio for MySQL. To use it, you should setup backup in the wizard manually and schedule making backups.