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
Preface: Recently, the company project changed th...
Table of contents UI Design Echarts example effec...
Array deduplication is usually encountered during...
We all know that the underlying data structure of...
I was working on a pop-up ad recently. Since the d...
undefined In JavaScript, if we want to determine ...
1. Command Introduction The ipcs command is used ...
Version update, the password field in the origina...
1. Introduction Containers use a sandbox mechanis...
The action of the form is different from the URL j...
Table partitioning is different from database par...
In order to provide high availability of the netw...
Tables once played a very important role in web p...
In the previous article, we introduced how to for...
Data Sheet /* Navicat SQLite Data Transfer Source...