This is one of the sections of my last article on security. It is a well-known fact that the MySQL database backup of your running Web site is extremely important.
Just follow the 3 steps below, and everything is under your control:
First Step: Configure the backup directory on the server
Code:
Mkdir/var/lib/mysqlbackup
Cd/var/lib/mysqlbackup
Step Two: Write a backup script
Code:
VI dbbackup.sh
Paste the following code, be sure to change the Username,password and dbname.
Code:
#!/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 Backup Script Permissions
Code:
chmod +x dbbackup.sh
Step three: Perform backup scripts with crontab timing
Code:
Crontab-e
If you back up 3 o'clock in the afternoon 20 daily, add the following code,
Code:
Get!