MySQL or mariadb backup script

Source: Internet
Author: User

#!/bin/bashdbuser=rootdbpasswd=123456dbbak1=mysql_testbackupdir1=/data/backup_v2/mysql_testbacktime= ' Date  +%y%m%d%h%m%s ' if [ ! -d  $BACKUPDIR 1 ];then         mkdir  $BACKUPDIR 1fiecho  "========== $BACKTIME   Database $dbbak1 backup start =========="  > >  $BACKUPDIR 1/mysql_test.logcd  $BACKUPDIR 1mysqldump --opt -r --triggers -e  --lock-all-tables --flush-logs --master-data=2 -u$dbuser -p$dbpasswd -- databases  $DBBAK 1 >  $DBBAK 1. $BACKTIME .sql 2>>  $BACKUPDIR 1/mysql_test.logif  [ $?==0 ];then        tar zcf  $DBBAK 1.$ backtime.tar.gz  $DBBAK 1. $BACKTIME .sql > /dev/null         rm -f  $BACKUPDIR 1/$DBBAK 1. $BACKTIME. Sql        echo  -e  "========= Database $dbbak1 Success!! =========\n " >>  $BACKUPDIR 1/mysql_test.logelse         echo -e  "========= Database $dbbak1  backup failed!! =========\n " >>  $BACKUPDIR 1/mysql_test.logfifind /data/backup_v2/mysql_test/ -mtime  +10 -delete


This article is from the "burning Years of Passion" blog, please be sure to keep this source http://liuzhengwei521.blog.51cto.com/4855442/1909887

MySQL or mariadb backup script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.