Automatic Remote Backup for mysql

Source: Internet
Author: User

Mysql databaseOfBackupThis makes database operations very simple and ensures the absolute security of databases in mysql databases. If the database is not backed up, the data in the database will be lost, and the staff will not be able to implement it, database Backup makes it easier for database administrators to manage databases. Nowadays, with the continuous development of technology, the automatic remote backup of mysql database has also been realized.

1. Implementing Local Automatic database backup is simple:

1. log in as root

2. scheduled tasks are automatically executed at every day/usr/bin/mysqlbackup)

Crontab
0 :30 ***/usr/bin/mysqlbackup

3. Write an automatic backup database script
Vi/usr/bin/mysqlbackup
#! /Bin/bash
Mv/home/.../db_bak5.tgz/home/.../db_bak6.tgz
Mv/home/.../db_bak4.tgz/home/.../db_bak5.tgz
Mv/home/.../db_bak3.tgz/home/.../db_bak4.tgz
Mv/home/.../db_bak2.tgz/home/.../db_bak3.tgz
Mv/home/.../db_bak1.tgz/home/.../db_bak2.tgz
Rm-rf/home/.../db_bak.txt
/Usr/bin/mysqldump-uroot-ppassword dbname
>/Home/.../db_bak.txt
Cd/home /.../
Tar czvf db_bak1.tgz db_bak.txt

2. The local directory/home /... /... /The system will prompt an error when the data is missing in the directory. This is normal.

3. Remote Backup can be implemented using ftp or scp commands. The method is simple. Check the usage of related commands and modify the mysqlbackup script.

In this article, we are happy to share this technique with you to implement automatic remote backup of the database in the mysql database. I hope it will be helpful to you.

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.