Use mysqlhotcopy of MySQL to implement the SH script source code for automatic Database Backup

Source: Internet
Author: User
Tags install perl


Use MySQL mysqlhotcopy to implement automatic database backup. the sh script source code can be added to the cortab at every day. Back up and package the MYSQL database. Set the source code of the file # crontab-e 0 1 ***/usr/local/src/backmysql. sh running www.2cto.com backmysql. sh for the scheduled task. You can configure the backup directory. The directory where the database name mysqlhotcopy is located, and the backup before the last 30 days can be deleted to avoid insufficient disk space. Success -------------------------------------------------------------------------------------------------------------------------#! /Bin/bash # yum-y install perl-DBD-MySQL // if mysqlhotcopy can't be runing, install it backdir = "/usr/local/backup/" mysqlbindir = "/usr/local/mysql/bin/" backdatabase = "cms" keepdays = 30 $ {mysqlbindir} mysqlhotcopy $ {backdatabase }$ {backdir} tar zcvfP $ {backdir }$ {backdatabase }_db _ $ (date + "% Y % m % d" -- date = "-1 day" ).tar $ {backdir }$ {backdatabase} www.2cto.com rm-rf $ {backdir }$ {backdatabase} _ db _ $ (date +" % Y % m % d "-- date ="-$ {keepdays} day "author Naola2001

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.