3 easy steps for scheduling regular backup of your MySql database: Be safe


Apart from my previous article on safety features ,it is a well known fact , that it is extremely important to take backup of your MySql database of your live website.

.

Just follow below 3 steps and everything is under control :

Step 1: Configure backup directory on server

1
2
mkdir /var/lib/mysqlbackup
cd /var/lib/mysqlbackup

.

Step 2: Make the backup script

1
    vi dbbackup.sh

.

Paste the content as below and change the username, password and dbname as required

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh
# Username to access the MySQL server
USERNAME="username"
# Username to access the MySQL server
PASSWORD="password"
# List of DBNAMES for Backup
DBNAME="dbname"
#date timestamp for log message
DATE=`/bin/date +%Y-%m-%d_%Hh%Mm`
#output file
OUTDIR="/var/lib/mysqlbackup/"
OUTFILE="ip_bindass".$DATE."sql.gz"
#working directory
DIR="/var/lib/mysqlbackup/"
#cd $DIR
# MySQL Backup
/usr/bin/mysqldump --database $DBNAME --opt --single-transaction -u$USERNAME -p$PASSWORD | /usr/bin/gzip -9 > $OUTDIR$OUTFILE

.

Change the permission of backup script

1
chmod +x dbbackup.sh

.

Step3: Schedule the backup script in crontab

1
crontab -e

.

Add below like to take backup everyday at 3.20 pm

1
20 15 * * * /var/lib/mysqlbackup/dbbackup.sh

.

All done!
Cheers!!

Recently Published

»

Why is Link Building So Important? Read this to understand

Getting a high ranking on search engine results is important to the ...

»

Productivity Tips for Web Developers for Efficient Time Management

The world is full of distractions. Whether you are a work-from-home, ...

»

The Importance of a Good Domain Name

The right domain name can genuinely make or break a business – ...

»

Cloud Strategy of Oracle: Working or Not?

Though Oracle considered cloud strategy as gibberish long before, it ...

»

Some Excellent SEO Tools for Boosting SEO Rankings like Never Before

You could be having a really great-looking website and the niftiest ...

»

How to Promote Your Business by Collecting Instagram Followers – Part 2

Promoting business is not an easy task these days with so many ...

»

Using Instagram to Optimize Your Business – Unfolding the Tricks – Part 1

Instagram is one of the most popular social networking communities ...

»

6 Mobile UX Design Techniques that work

In software development, be it a mobile app or a website, creating ...

»

Importance of website design in online branding

“A brand for a company is like a reputation for a person. You earn ...