https://github.com/bartekl1/mysql-backup
๐ฆ A simple bash script to automate MySQL database backups with options for compression and upload.
https://github.com/bartekl1/mysql-backup
backup backup-script backup-tool backup-utility backups database database-backup database-backup-scripts databases mysql mysql-backup
Last synced: 5 months ago
JSON representation
๐ฆ A simple bash script to automate MySQL database backups with options for compression and upload.
- Host: GitHub
- URL: https://github.com/bartekl1/mysql-backup
- Owner: bartekl1
- License: other
- Created: 2025-06-03T16:30:04.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-08-30T16:11:12.000Z (6 months ago)
- Last Synced: 2025-08-30T18:18:27.210Z (6 months ago)
- Topics: backup, backup-script, backup-tool, backup-utility, backups, database, database-backup, database-backup-scripts, databases, mysql, mysql-backup
- Language: Shell
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ฆ MySQL Backup Script
A simple bash script to automate MySQL database backups with options for compression and upload.
## โน๏ธ About
I created this script with ChatGPT because I quickly needed a database backup script for [my weather station](https://github.com/bartekl1/meteo). \
I do not plan to maintain it, but if you find it useful, feel free to use it.
## โจ Features
- ๐พ Local MySQL database backups using `mysqldump`
- ๐ฆ Optional compression using `gzip`
- โ๏ธ Optional remote upload via [rclone](https://rclone.org/)
- ๐งน Optional cleanup of old local backups
## ๐ง Installation and usage
1. Install dependencies:
- `mysqldump` (part of MySQL client tools)
- `gzip` (optional for compression, usually pre-installed on most Linux distributions)
- `rclone` (optional for remote uploads, see [rclone installation guide](https://rclone.org/install/))
2. Clone the repository.
```bash
git clone https://github.com/bartekl1/mysql-backup.git
cd mysql-backup
cp backup.example.conf backup.conf
```
Instead of cloning the repository, you can also download the `backup.sh` script directly.
```bash
wget https://raw.githubusercontent.com/bartekl1/mysql-backup/refs/heads/main/backup.sh
wget https://raw.githubusercontent.com/bartekl1/mysql-backup/refs/heads/main/backup.example.conf -O backup.conf
```
3. Edit `backup.conf` configuration file. See the [Configuration](#configuration) section for more details.
4. Make the script executable.
```bash
chmod +x backup.sh
```
5. Manually run the script to test it.
```bash
./backup.sh
```
6. (Optional) Set up a cron job to automatically run the script at the desired time.
```bash
crontab -e
```
Example (backup every day at 2 AM):
```text
0 2 * * * bash /path/to/backup.sh
```
## โ๏ธ Configuration
The script can be configured via the `backup.conf` file. \
Example configuration file is available in [`backup.example.conf`](backup.example.conf). \
See comments in the file for explanation of each option.
## ๐ License
This project is licensed under [Zero-Clause BSD License](LICENSE). \
This means you can freely use, modify, and redistribute the code for commercial and non-commercial purposes without attribution.