You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-6Lines changed: 33 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ This is a simple backup script for MySQL servers, designed to help you easily ba
12
12
Before you can use this tool, make sure you have the following prerequisites installed on your system:
13
13
14
14
-**MySQL Client**: Ensure that you have the MySQL client installed to interact with your MySQL databases.
15
+
-**GNU Parallel**: Required to run backup jobs concurrently.
15
16
16
17
## Setup
17
18
@@ -33,21 +34,23 @@ Before you can use this tool, make sure you have the following prerequisites ins
33
34
-`db_host`: The hostname or IP address of your MySQL server.
34
35
-`db_user`: The MySQL user with backup privileges.
35
36
-`db_pass`: The password for the MySQL user.
36
-
-`max_parallel`: The maximum number of parallel database backups.
37
+
-`max_parallel`: The maximum number of parallel database backups, or `auto`.
38
+
-`max_parallel_cap`: Upper bound when `max_parallel=auto`.
39
+
-`mysql_connection_reserve`: Number of MySQL connections reserved for non-backup traffic when `max_parallel=auto`.
37
40
-`max_backups`: The maximum number of backup sets to retain.
38
41
39
42
4. Make sure the script file is executable.
40
43
41
44
```bash
42
-
chmod +x backup.sh
45
+
chmod +x dump.sh
43
46
```
44
47
45
48
## Usage
46
49
47
-
To create database backups using this tool, simply run the `backup.sh` script:
50
+
To create database backups using this tool, simply run the `dump.sh` script:
48
51
49
52
```bash
50
-
./backup.sh
53
+
./dump.sh
51
54
```
52
55
53
56
The script will perform the following actions:
@@ -60,12 +63,36 @@ The script will perform the following actions:
60
63
61
64
4.**Cleanup Old Backups**: It checks the number of backup sets and removes old backups if the number exceeds the `max_backups` setting.
62
65
66
+
## Concurrency Tuning
67
+
68
+
For large MySQL servers (for example 400+ databases), set:
69
+
70
+
```bash
71
+
max_parallel=auto
72
+
max_parallel_cap=16
73
+
mysql_connection_reserve=20
74
+
```
75
+
76
+
With `auto`, the script computes parallel jobs from:
77
+
78
+
- detected CPU core count
79
+
- MySQL `max_connections` minus `mysql_connection_reserve`
80
+
-`max_parallel_cap`
81
+
82
+
The minimum of these values is used as job count.
83
+
84
+
Guidelines:
85
+
86
+
- Many small databases: increase `max_parallel_cap` carefully and observe DB load.
87
+
- Few large databases: lower cap can reduce I/O contention and stabilize runtime.
88
+
- Busy production DB: increase `mysql_connection_reserve` to protect foreground traffic.
89
+
63
90
## Example
64
91
65
92
Here's an example of how to run the backup script:
66
93
67
94
```bash
68
-
./backup.sh
95
+
./dump.sh
69
96
```
70
97
71
98
## License
@@ -78,4 +105,4 @@ This backup tool is released under the MIT License. See the [LICENSE](LICENSE) f
78
105
79
106
---
80
107
81
-
That's it! You now have a simple backup tool to help you manage your MySQL database backups. If you encounter any issues or have suggestions for improvements, feel free to open an issue on GitHub or contribute to the project.
108
+
That's it! You now have a simple backup tool to help you manage your MySQL database backups. If you encounter any issues or have suggestions for improvements, feel free to open an issue on GitHub or contribute to the project.
0 commit comments