backup mysql database on local linux server

From WebHostingNeeds.com
Jump to: navigation, search
mkdir /usr/hostonnet/

Create a file

vi /usr/hostonnet/mysql_backup.sh

Add

#!/bin/sh
# LOCAL LINUX

BFILE=/www/web/demo/sql/wiki-$(date +%m%d%Y_%k).sql
/usr/bin/mysqldump -u root -pflashwebhost wiki > $BFILE

BFILE=/www/web/demo/sql/boby_vshare-$(date +%m%d%Y_%k).sql
/usr/bin/mysqldump -u root -pflashwebhost boby_vshare > $BFILE

BFILE=/www/web/demo/sql/jobin_vshare-$(date +%m%d%Y_%k).sql
/usr/bin/mysqldump -u root -pflashwebhost jobin_vshare > $BFILE

BFILE=/www/web/demo/sql/suneesh_vshare-$(date +%m%d%Y_%k).sql
/usr/bin/mysqldump -u root -pflashwebhost suneesh_vshare > $BFILE

Set permission

chmod 755 /usr/hostonnet/mysql_backup.sh


Set cronjob

crontab -e

Add

0 11 * * * /usr/hostonnet/mysql_backup.sh

mycomputer