Go centos-mysql backup Shell script

Source: Internet
Author: User
Tags mysql backup

Http://www.cnblogs.com/bruceleeliya/archive/2012/05/04/2482733.html

use mysqldump to back up the database, upload to the backup server via FTP, and keep the backup files locally.

Create a new Shell script file

vi/home/work/backup.sh

Add the following content:

#! /bin/bashsqlbakname=_u1_sql_$ (date +%y%m%d). Tar.gzmysqldump--user=mysql_user1--password= "Your password"-- Lock-all-tables--all-databases > Backup.sqltar zcvf $SqlBakName backup.sql#ftp to your SERVERFTP-NV 192.168.1.100 < ;< eofuser ftp_user1 "Password1" Cd/home/mysql_backup/put $SqlBakNamequitEOFrm-F backup.sqlmv $SqlBakName/home/ mysql_backup/$SqlBakName

Press: Wq Save and exit

* Add a script to a timed startup item

1 Create a new Cronfile file

Vi/home/work/backup_cronfile

2 Add the following:

XX * * * */home/work/backup.sh

Press: Wq Save and exit

00 00 * * * indicates that the backup.sh file is executed at 0 points per day.

3 Enter the following command:

Crontab/home/work/backup_cronfile

Go centos-mysql backup Shell 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.