Use the system crontab to execute backup files regularly and save the backup results by date to achieve the purpose of backup. 1. Create a path to save the backup file /mysqldata#mkdir /mysqldata 2. Create /usr/sbin/bakmysql file#vi /usr/sbin/bakmysql enter rq= date +%Y%m%d tar zcvf /mysqldata/mysql$rq.tar.gz /var/lib/mysql Or written as rq= date +%Y%m%d mysqldump –all-databases -u root -p password > /mysqldata/mysql$rq.sql /var/lib/mysql is the directory where your database files are located. Some users may have /usr/local/mysql/data. This may be different for each user. /mysqldata/ indicates the directory where backup files are saved. Everyone can do this according to their own requirements. 3. Modify the file attributes to make it executable# chmod +x /usr/sbin/bakmysql 4. Modify /etc/crontab#vi /etc/crontab Add below 01 3 * * * root /usr/sbin/bakmysql Indicates that the backup is performed at 3 o'clock every day 5. Restart crond# /etc/rc.d/init.d/crond restart Finish. So every day you can see such files in /mysqldata mysql20040619.tar.gz You can just download it. Well, the above is how to quickly use crontab to schedule backup of MySQL in Linux system. For more information about the use of crontab, please see the following related articles You may also be interested in:
|
<<: js uses FileReader to read local files or blobs
>>: Detailed process of building mongodb and mysql with docker-compose
Table of contents Preface The role of render Rend...
When we write some UI components, if we don't...
Network security is a very important topic, and t...
Environmental Description Server system: Ubuntu 1...
1. Introduction Some time ago, there were a serie...
Shell Script #!/bin/sh # Current directory CURREN...
This article collects the fonts used in the logos...
After starting Docker, let's take a look at t...
How to use the MySQL authorization command grant:...
Problem Description A Spring + Angular project wi...
Table of contents Cache function in vue2 Transfor...
Table of contents Introduction to WiFi Wireless T...
This article example shares the specific code of ...
Rendering Define the skeleton, write HTML and CSS...
Method 1: Use lsof command We can use the lsof co...