Friday, June 18, 2010

Toddlercon English Manga

Auto Backup MySQL Database using + Shell Scripting crontab Crontab

Linux Shell Scripting is a series of commands written in plain text files, and text files are called to run a command in it.

Command in linux shell diverse as create / update / delete files or folders sebua, mounting, until able to backup the database.

While Crontab is a scheduling application on linux that allows for automatic execution of programs / applications / scripts with the scheduled time.

So with two Linux capabilities is a complete combination to create a backup database automatically and scheduled.

Below are step by step to make the Auto Backup MySQL Database

1. Create all files, for example In that file write linux shell scripting , as below:
v_tgl = `date +% Y% m% d_% H% M% S`;
v_name = bukutamu_ $ v_tgl.sql;
mysqldump-uroot-ppass guestbook> / home / dendie / Desktop / $ v_name;

This script is a scripting shell that do dump / backup of a database named guestbook to address / home / dendie / Desktop /

While the scripts that perform database backup is
mysqldump-uroot-ppass guestbook> / home / dendie / Desktop / $ v_name;

variable $ vname naming format file containing the results shell script that is used as the name of the dump / backup the database.

example of the backup is bukutamu_20100128_203001.sql

While the script that makes a file-naming format is

v_tgl = `date +% Y% m% d_% H% M% S`;
v_name = bukutamu_ $ v_tgl . sql;

2. Set file as
execute files sudo chmod + x

3. At the command line set Crontab / Scheduling for execution files
sudo crontab-e

then typed as below
* / 5 * * * * / home / dendie / Desktop / my_data /> / home / dendie / Desktop / auto_backup.log
The above examples make crontab / scheduling for the execution file every 5 minutes once and create logs / records to a file auto_backup.log event of trouble during execution.


Post a Comment