Facebook
Banner
XMPP JavaScript Library READ MORE

Small Linux shell script to backup MySQL Database

Linux, Sachin Puri, 2012-01-27 16:29:37

This shell script can be used to take mysql database backup. To make backup process automatically you have to call this shellscript using Cron Job.

#!/bin/sh
#MySQL Database Backup Script
#-----------------------------

#Config
DB="database" #Database to backup
USER="user" #Your MySQL User
PASS="password" #Your MySQL Password
BACKUP_DIR="/root/backup" #Path to your backup directory
MYSQL_BIN_DIR="/var/mysql/bin" #Path to your MySQL bin folder
#Config

DT=`date '+%d_%b_%Y_%H_%M_%S'`
FILE=$BACKUP_DIR/$DB'_DB_BK_'$DT.sql

$MYSQL_BIN_DIR/mysqldump $DB > $FILE -u $USER -p$PASS
gzip $FILE

 

Add Your Comment
   
    Yes! I want to receive all comments by email

  by rajapoker on 25-Jun-2019 04:41 pm
tetap semangat dan selalu jilat
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by Anonymous on 28-Jan-2012 08:49 pm
Thanks for the script.
  • Reply
  •  8 Like
  •  3 Dislike
  • Report