Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

πŸ“¦ A simple bash script to automate MySQL database backups with options for compression and upload.

License

bartekl1/mysql-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

3 Commits

Repository files navigation

πŸ“¦ MySQL Backup Script

A simple bash script to automate MySQL database backups with options for compression and upload.

i️ About

I created this script with ChatGPT because I quickly needed a database backup script for my weather station.
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
  • 🧹 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)
  1. Clone the repository.
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.

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
  1. Edit backup.conf configuration file. See the Configuration section for more details.

  2. Make the script executable.

chmod +x backup.sh
  1. Manually run the script to test it.
./backup.sh
  1. (Optional) Set up a cron job to automatically run the script at the desired time.
crontab -e

Example (backup every day at 2 AM):

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.
See comments in the file for explanation of each option.

πŸ“œ License

This project is licensed under Zero-Clause BSD License.
This means you can freely use, modify, and redistribute the code for commercial and non-commercial purposes without attribution.

About

πŸ“¦ A simple bash script to automate MySQL database backups with options for compression and upload.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /