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

mkdir /var/lib/mysqlbackup
cd /var/lib/mysqlbackup

.

Step 2: Make the backup script

    vi dbbackup.sh

.

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

#!/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

chmod +x dbbackup.sh

.

Step3: Schedule the backup script in crontab

crontab -e

.

Add below like to take backup everyday at 3.20 pm

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

.

All done!
Cheers!!

Recently Published

»

Is Your Business Site Fully Accessible?

Does your business site have full accessibility? Even with the ADA ...

»

Secure Web: 5 Best Practices For Application Development

There are several essential best practices for secure web ...

»

Laravel PHP Framework: Features and benefits for web development

Companies and organizations are focusing on developing custom web ...

»

Web Development Vs. Software Development: What Is the Difference?

As technology continues to transform all aspects of our lives, a lot ...

»

Web Redesign : Is Your Landing Page Begging for one?

How do you know when it’s time to web redesign your landing page? ...

»

Customer Acquisition: Few Steps To Improve This.

Customer acquisition is essential to any business’s success — to ...

»

Mobile App Development Tools: 5 Enterprise-Ready For Rapid Deployment

There are several enterprise-ready mobile app development tools for ...

»

Docker: How To Build Better Development Security With It

The top concern among developers and DevOps teams is security within ...

»

Mobile Development: How to Reduce Costs

Modern markets have become so competitive that it has become vital ...