Giter Site home page Giter Site logo

mysqlbackup's Introduction

Backup Your MySQL Databases to Disk, FTP, and Email

This is a shell script that backs up your MySQL servers. It can talk to as many servers as you'd like (remote or local), and has some features to filter out specific databases and table names.

Requirements

To backup databases locally, you'll only need bash and gzip, which ship with just about all Linux distros.

To backup to FTP, you'll need the 'ftp' program.

To backup to email, you'll need the 'mutt' program.

Available options

MySQL Settings

DBNAMES

Databases you want to backup, separated by a space; leave empty to backup all databases on this host.

Example:

DBNAMES[0]="db1 db2"

DBUSER

Your MySQL username.

Example:

DBUSER[0]="root"

DBPASS

Your MySQL password.

Example:

DBPASS[0]="password"

DBHOST

Your MySQL server's location (IP address is best).

Example:

DBHOST[0]="localhost"

DBTABLES

Tables you want to backup or exclude, separated by a space; leave empty to back up all tables.

Example:

DBTABLES[0]="db1.table1 db1.table2 db2.table1"

DBTABLESMATCH

If you set this to 'include', it will backup ONLY the tables in DBTABLES, 'exclude' will backup all tables BUT those in DBTABLES.

Example:

DBTABLESMATCH[0]="include"

DBOPTIONS

If you want to give mysqldump other options, include them here.

Example:

DBOPTIONS[0]="--quick --single-transaction"

Email Settings

EMAILS

Email addresses to send backups to, separated by a space.

Example:

EMAILS="[email protected] [email protected]"

SUBJECT

This is the subject of the email that you'll get.

Example:

SUBJECT="MySQL backup on $SERVER ($DATE)"

FTP Settings

FTPHOST
Example:

FTPHOST[0]="ftphost"

FTPUSER
Example:

FTPUSER[0]="username"

FTPPASS
Example:

FTPPASS[0]="password"

FTPDIR
Example:

FTPDIR[0]="backups"

Backing up multiple servers

For each server you're backing up, you will need to copy/paste the block under MySQL Settings and increment the key in brackets (e.g. the first server will be 0, the next will be 1, and so on).

mysqlbackup's People

Contributors

ameir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mysqlbackup's Issues

Cannot connect to a different port.

MySQL Server is running on 3340, script fails to connect.

DBHOST[0]="127.0.0.1:3340"
Error - Got error: 2005: Unknown MySQL server host '127.0.0.1:3340' (2) when trying to connect.

Update documentation

S3 sync and Duplicity support have been added, but documentation does not reflect it. Creating this issue to keep this on my radar.

Add Variable for Sleep time post SQL dump

One of my sizes has a sizeable DB, and began running into an issue where the mySQL DB would not be finished dumping before the script attempted to compress it. This was resolved by adding a "sleep 10" line in the script, to give it time to finish.

If this pertains to larger databases, and more time might be needed, I would suggest adding a Sleep variable that can be set in the config, so that larger sites can have a higher pause before moving on to the compression. (Optionally, if the size of the DB can be easily determined, have the script estimate a sleep time based off the size of the DB.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.