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

»

Modern Changes That You Should Consider for Your Web Site

Websites need to modernize and get updated periodically otherwise ...

»

Super Tips For A Flawless Website

A website has a specific purpose. And your job is to design a website ...

»

Wix Offers Best Free Web Apps for Artists and Photographers

The famous online website builder Wix is known for providing the ...

»

What You Should Know Before Setting Up a Digital Marketing and Web Design Company

Running a digital marketing and web designing company can be a ...

»

Important Factors to Think About When Starting a Mailing List

Many bloggers and business owners don’t have a mailing list, ...

»

Tried and Tested Strategies for Boosting eBook Sales

As you have by now realized, writing your ebook was just the first ...

»

What Really Makes a Website User-Friendly

Whether it’s for business or personal use, having a website online ...

»

5 Features of Virtual Private Server that put you in complete Control of Your Website

For a decade now, virtual private server has been a preferred hosting ...

»

8 Ways the Right Ecommerce Platform Makes Your Business Perform Better

Starting your own ecommerce store is an exciting experience, but ...