vinugawade / ms-bkp

Bash script to backup all mysql databases as separate compressed files.

Home Page:https://vinugawade.github.io/ms-bkp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MySQL Database Backup Script πŸ—„οΈ

Linux MacOS Windows Windows

GitHub issues GitHub code size in bytes GitHub last commit

If you need to backup MySQL databases on a Linux / MacOS / Windows system, the ms-bkp script provides an easy-to-use solution. It allows you to export databases, skip specific ones, and set the destination path for the backup.


Installation πŸš€

  1. Clone the Repository:

    • Clone the ms-bkp repository to your local machine using the following command:
    git clone https://github.com/vinugawade/ms-bkp.git
  2. Move the Script to a Global Location:

    • Move the script to a global location on your system using the following command:
    sudo mv /location/of/ms-bkp /usr/local/bin
  3. Set Script Permissions:

    • Allow everyone to execute the script by choosing one of the following commands:
    sudo chmod +x /location/of/ms-bkp

    OR

    sudo chmod 0755 /location/of/ms-bkp
  4. Add to $PATH:

    • Add /usr/local/bin to your $PATH. If you use the Bash shell, execute the command:
    export PATH=$PATH:/usr/local/bin

    OR

    export PATH=$PATH:/location/of/ms-bkp

    This will set the variable name, potentially in a file like ~/.bash_profile, ~/.bashrc, or ~/.profile. If you're unsure where to put it, ~/.bashrc is a good choice.

You may need to restart your shell for this to take effect.


Script Options πŸŽ›οΈ

The ms-bkp script supports the following options:

  • -u, --user: MySQL username
  • -p, --password: MySQL password
  • -o, --only: Export only the specified database
  • -s, --skip: Skip specified databases during export (comma-separated)
  • -d, --dest: Destination path for the backup (default: ~/Downloads)

Usage πŸ› οΈ

Now you can use the script from anywhere in the terminal. Below are some examples.

ms-bkp -u your_mysql_user -p your_mysql_password -o your_database_name
ms-bkp -u your_mysql_user -p your_mysql_password -s db1,db2,db3 -d /path/to/backup

Check below attached GIF.

Run ms-bkp script


Maintainer πŸ‘¨πŸ»β€πŸ’»

Vinay Gawade's Dev Card

Built With πŸ’™βœ¨ By Vinay Gawade.

LinkedIn Logo Buy Me a Coffee Logo Twitter Logo

License πŸ›‚

LICENSE

This project is licensed under the LICENSE file associated with this repository.

About

Bash script to backup all mysql databases as separate compressed files.

https://vinugawade.github.io/ms-bkp

License:MIT License


Languages

Language:Shell 100.0%