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.