Skip to content

Commit d2d9458

Browse files
DeepAnchorjameswpm
authored andcommitted
Fix translation for section "MySQL backup" in 12.4.md
1 parent e1d513b commit d2d9458

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

en/12.4.md

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,43 +68,44 @@ In order to periodically synchronize files, you can set up a crontab file that w
6868

6969
## MySQL backup
7070

71-
MySQL database application is still the mainstream, the current MySQL backup in two ways: hot backup and cold backup, hot backup is currently mainly used master/slave mode (master/slave) mode is mainly used for database synchronization separate read and write, but also can be used for hot backup data ), on how to configure this information, we can find a lot. Cold backup data, then that is a certain delay, but you can guarantee that the time period before data integrity, such as may sometimes be caused by misuse of our loss of data, then the master/slave model is able to retrieve lost data, but through cold backup can partially restore the data.
71+
MySQL databases are still the mainstream, go-to solution for most web applications. The two most common methods of backing up MySQL databases are hot backups and cold backups. Hot backups are usually used with systems set up in a master/slave configuration to backup live data (the master/slave synchronization mode is typically used for separating database read/write operations, but can also be used for backing up live data). There is a lot of information available online detailing the various ways one can implement this type of scheme. For cold backups, incoming data is not backed up in real-time as is the case with hot backups. Instead, data backups are performed periodically. This way, if the system fails, the integrity of data before a certain period of time can still be guaranteed. For instance, in cases where a system malfunction causes data to be lost and the master/slave model is unable to retrieve it, cold backups can be used for a partial restoration.
7272

73-
Cold backup shell script is generally used to achieve regular backup of the database, and then rsync synchronization through the above described non-local one server room.
73+
A shell script is generally used to implement regular cold backups of databases, executing synchronization tasks using rsync in a non-local mode.
7474

75-
The following is a scheduled backup MySQL backup script, we use the mysqldump program, this command can be exported to a database file.
75+
76+
The following is an example of a backup script that performs scheduled backups for a MySQL database. We use the `mysqldump` program which allows us to export the database to a file.
7677

7778

7879
#!/bin/bash
79-
# The following configuration information, modify their own
80+
# Configuration information; modify it as needed
8081
mysql_user="USER" #MySQL backup user
8182
mysql_password="PASSWORD" # MySQL backup user's password
8283
mysql_host="localhost"
8384
mysql_port="3306"
84-
mysql_charset="utf8" # MySQL coding
85-
backup_db_arr=("db1" "db2") # To back up the database name, separated by spaces separated by a plurality of such("db1" "db2" "db3")
86-
backup_location=/var/www/mysql # backup data storage location, please do not end with a "/", this can keep the default, the program will automatically create a folder
87-
expire_backup_delete="ON" # delete outdated backups is turned OFF to ON ON to OFF
88-
expire_days=3 # default expiration time for the three days the number of days, this is only valid when the expire_backup_delete open
89-
90-
# We do not need to modify the following start
91-
backup_time=`date +%Y%m%d%H%M` # define detailed time backup
92-
backup_Ymd=`date +%Y-%m-%d` # define the backup directory date time
85+
mysql_charset="utf8" # MySQL encoding
86+
backup_db_arr=("db1" "db2") # Name of the database to be backed up, separating multiple databases wih spaces ("DB1", "DB2" db3 ")
87+
backup_location=/var/www/mysql # Backup data storage location; please do not end with a "/" and leave it at its default, for the program to automatically create a folder
88+
expire_backup_delete="ON" # Whether to delete outdated backups or not
89+
expire_days=3 # Set the expiration time of backups, in days (defaults to three days); this is only valid when the `expire_backup_delete` option is "ON"
90+
91+
# We do not need to modify the following initial settings below
92+
backup_time=`date +%Y%m%d%H%M` # Define the backup time format
93+
backup_Ymd=`date +%Y-%m-%d` # Define the backup directory date time
9394
backup_3ago=`date-d '3 days ago '+%Y-%m-%d` # 3 days before the date
94-
backup_dir=$backup_location/$backup_Ymd # full path to the backup folder
95-
welcome_msg="Welcome to use MySQL backup tools!" # greeting
95+
backup_dir=$backup_location/$backup_Ymd # Full path to the backup folder
96+
welcome_msg="Welcome to use MySQL backup tools!" # Greeting
9697

97-
# Determine whether to start MYSQL, mysql does not start the backup exit
98+
# Determine whether to MySQL is running; if not, then abort the backup
9899
mysql_ps=`ps-ef | grep mysql | wc-l`
99100
mysql_listen=`netstat-an | grep LISTEN | grep $mysql_port | wc-l`
100101
if [[$mysql_ps==0]-o [$mysql_listen==0]]; then
101-
echo "ERROR: MySQL is not running! backup stop!"
102+
echo "ERROR: MySQL is not running! backup aborted!"
102103
exit
103104
else
104105
echo $welcome_msg
105106
fi
106107

107-
# Connect to mysql database, can not connect to the backup exit
108+
# Connect to the mysql database; if a connection cannot be made, abort the backup
108109
mysql-h $mysql_host-P $mysql_port-u $mysql_user-p $mysql_password << end
109110
use mysql;
110111
select host, user from user where user='root' and host='localhost';
@@ -113,11 +114,11 @@ The following is a scheduled backup MySQL backup script, we use the mysqldump pr
113114

114115
flag=`echo $?`
115116
if [$flag!="0"]; then
116-
echo "ERROR: Can't connect mysql server! backup stop!"
117+
echo "ERROR: Can't connect mysql server! backup aborted!"
117118
exit
118119
else
119120
echo "MySQL connect ok! Please wait......"
120-
# Judgment does not define the backup database, if you define a backup is started, otherwise exit the backup
121+
# Determine whether a backup database is defined or not. If so, begin the backup; if not, then abort
121122
if ["$backup_db_arr"!=""]; then
122123
# dbnames=$(cut-d ','-f1-5 $backup_database)
123124
# echo "arr is(${backup_db_arr [@]})"
@@ -128,36 +129,38 @@ The following is a scheduled backup MySQL backup script, we use the mysqldump pr
128129
`mysqldump -h $mysql_host -P $mysql_port -u $mysql_user -p $mysql_password $dbname - default-character-set=$mysql_charset | gzip> $backup_dir/$dbname -$backup_time.sql.gz`
129130
flag=`echo $?`
130131
if [$flag=="0"]; then
131-
echo "database $dbname success backup to $backup_dir/$dbname-$backup_time.sql.gz"
132+
echo "database $dbname successfully backed up to $backup_dir/$dbname-$backup_time.sql.gz"
132133
else
133-
echo "database $dbname backup fail!"
134+
echo "database $dbname backup has failed!"
134135
fi
135136
136137
done
137138
else
138-
echo "ERROR: No database to backup! backup stop"
139+
echo "ERROR: No database to backup! backup aborted!"
139140
exit
140141
fi
141-
# If you open the delete expired backup, delete operation
142+
# If deleting expired backups is enabled, delete all expired backups
142143
if ["$expire_backup_delete"=="ON" -a "$backup_location"!=""]; then
143144
# `find $backup_location/-type d -o -type f -ctime + $expire_days-exec rm -rf {} \;`
144145
`find $backup_location/ -type d -mtime + $expire_days | xargs rm -rf`
145146
echo "Expired backup data delete complete!"
146147
fi
147-
echo "All database backup success! Thank you!"
148+
echo "All databases have been successfully backed up! Thank you!"
148149
exit
149150
fi
150151

151152

152-
Modify shell script attributes:
153+
Modify the properties of the shell script like so:
153154

154155
chmod 600 /root/mysql_backup.sh
155156
chmod +x /root/mysql_backup.sh
156157

157-
Set attributes, add the command crontab, we set up regular automatic backups every day 00:00, then the backup script directory/var/www/mysql directory is set to rsync synchronization.
158+
Then add the crontab command:
158159

159160
00 00 *** /root/mysql_backup.sh
160161

162+
This sets up regular backups of your databases to the `/var/www/mysql` directory every day at 00:00, which can then be synchronized using rsync.
163+
161164
## MySQL Recovery
162165

163166
Earlier MySQL backup into hot backup and cold backup, hot backup main purpose is to be able to recover in real time, such as an application server hard disk failure occurred, then we can modify the database configuration file read and write into slave so that you can minimize the time interrupt service.

0 commit comments

Comments
 (0)