Preface: Basically, whether it is for our own use or deploying servers for customers, MySQL backup is an indispensable part. Here I will share with you how I achieve automatic off-site backup on Linux.
1. Data backup preparation 1.1 Create a backup directory
Create a folder (if it has been created, please ignore it) mkdir -p /data/backup/mysql cd /data/backup 1.2 Create a script file Create mysql_backup.sh Script
Paste the following script content #!/bin/bash # If necessary, change this yourself #db_user='root' #db_password=`cat /data/www/mysql_password` db_name='wuqilong' backup_dir='/data/backup/mysql/' current_time=$(date +'%Y-%m-%d_%H%M%S') filepath=$backup_dir$current_time'.sql.gz' #$db_password $db_user is not used here, it has been written into the configuration file echo 'Start exporting the database...' mysqldump --defaults-extra-file=/data/backup/my_mysql.cnf $db_name | gzip > $filepath echo 'Export successful, file name: '$filepath Create a new configuration file in our current directory, i.e. /data/backup
The following is the file content. Here you can set the upper limit of the file size allowed to be exported The host here is the server you need to back up from. [mysqldump] max_allowed_packet = 400M host=ip address (192.168.1.**) user=root password='root' [mysql] host=ip address (192.168.1.**) user=root password='root' The exported shell script is now ready. Next, add permissions to it.
Now you can use the following command to export sh ./mysql_backup.sh # Check the results ll ./mysql Summarize This is the end of this article about MySQL automatic remote backup under Linux. For more information about MySQL automatic remote backup under Linux, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Modification of time zone problem of MySQL container in Docker
>>: This article teaches you how to import CSS like JS modules
1. Why set maxPostSize? The tomcat container has ...
Table of contents 1. Introduction 2. Use axios in...
This article example shares the specific code of ...
Let's take a look at the problem of VScode re...
The installation tutorial of MySQL 5.7.19 winx64 ...
This article example shares the specific code of ...
Table of contents Overview console.log console.in...
Problem: The MySQL database crashed unexpectedly ...
Preface Recently, I encountered such a problem wh...
A major feature of the WeChat 8.0 update is the s...
Download MySQL-8.0.23 Click to download: mysql-8....
1. Cancel the blue color of the a tag when it is ...
Table of contents 1. When inserting or modifying ...
Table of contents 1. What is Proxy? 2. How to use...
This tutorial shares the process of manually inst...