MySql backup script

This mysql database shell (bash download link at the end of script) script can be used:

1) To backup databases file /backup dir and later pick up by your script

2) You can skip few databases from backup!

Download script from above url.

Open file backup.bash.txt and customize it:
MyUSER=”YOUR-MYSQL-USER” # mysql username
MyPASS=”YOUR-MYSQL-USER-PASSWORD” # mysql password
MyHOST=”localhost” # mysql Hostname

Optional setup the name of database which you do not wish to backup:
IGGY="test db2 db3"

Rename backup.bash.txt file to mysqlbackup.bash and execute it as follows
$ ./mysqlbackup.bash

You may need to setup a cron job to take backup everyday.

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
23 comments… add one
  • Ô±Õ¬Õ¥Ö„Õ½Õ¡Õ¶Õ¤Ö€ May 21, 2012 @ 10:35

    Hello
    I must repeat Karo’s question:
    What is the

    # Store list of databases
    DBS=””
    leave bank or can insert an option


    Also i include some dbs in iggy field

    IGGY=”test db2 db3″

    but script backups all databases of the server (even test and information_schema)

    How to fix it ?

  • Lucian Daniliuc Jun 12, 2011 @ 11:10

    Great script! Thanks a lot!

  • cyberdesigner.net Jul 27, 2009 @ 8:29

    @Mark:

    better use
    NOW=”$(date +”%d-%m-%Y-%H-%M”)”

    because if you make backups on each hour you have 2009-07-27-10-00 twice a day 😉

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.