Projects / MySQL Backup

MySQL Backup

MySQL Backup is a Perl script that uses mysqlshow to grab the database names and "show tables" to grab the table names for a user's account, and then uses mysqldump to save the data in a subdirectory named in the script. It then tars and gzips the files, using the date and time for the file name. It can be run from cron on a daily basis. It removes old files and has an option to email the gzip file to an admin, and/or FTP the file to a remote server. It also has options to use "select data into outfile" or a regular "select" for users who can't use mysqldump. It supports LARGE sets of databases and tables.

Tags
Licenses
Implementation

Recent releases

  •  14 Sep 2008 19:20

    Release Notes: Code to correctly delete remote FTP files by forcing a check on the remote directory name and setup variable. Code to remove '.' and '..' from the remote FTP list of files. Code to not break if the remote FTP directory didn't have any files in it. Code to delete remote FTP files based on the variable $number_of_files_to_save.

    •  24 Dec 2003 03:36

      Release Notes: This release fixes a bug in the mysqldump parameters. Code was also added to the FTP upload feature.

      •  18 May 2003 08:35

        Release Notes: This version includes options to refine the tar/gzip functions. mysqldump now uses --result-file. The script can now be run from the Web, with password protection, and now works on both Linux and Windows. A bug with parsing of whereis output was fixed. A significant amount of error checking was added. The reporting method was cleaned up. A switch to disable reporting to stdout was added, and a method for selecting method of output (screen, email or both) was created.

        •  11 Jun 2002 17:16

          Release Notes: A small bugfix (comments are required in front of 'use' statements for Net::FTP and MIME::Lite if those libraries aren't installed), and some code and instructions have been reworked.

          •  10 Jun 2002 18:08

            Release Notes: An option to FTP backup a file to a remote server has been added. There are additional small features and one bugfix.

            Recent comments

            04 Aug 2004 06:16 wfmh

            Re: It does what it says and is quite cool
            More less same in bash - not for general use out of the box but just copy of one of my tools. Probably would need some tweaking for others (i.e. I do md5sum twice for each dump - you may not be so adminish ;)


            #!/bin/bash

            TARGET=/BACKUP

            export DT=`date +"%Y%m%d_%H%M"`

            export DESTDIR=${TARGET}/`date +"%Y%m%d/mysql"`

            TMPNAME=_dump_sql_tmp_$$

            function Backup()

            {

            local SERVER

            SERVER=$1

            BASE="$SERVER"_${DT}

            CURDIR=`pwd`

            echo " ${SERVER} to ${BASE}: "

            DEST=${DESTDIR}/${SERVER}/${DT}

            mkdir -p ${DEST}

            cd ${DEST}

            # getting list of databases...

            echo "SHOW DATABASES;" | mysql -pPASSWORD -u USER -h ${SERVER} > ${TMPNAME}

            while read DB

            do

            if [ $DB != "Database" ]; then

            echo -n " ${DB}: "

            mysqldump -Q --all --complete-insert --quote-names --add-drop-table -pPASSWORD -u USER -h ${SERVER} ${DB} >${BASE}_${DB}.mysql

            echo -n "md5"

            md5sum -b ${BASE}_${DB}.mysql >${BASE}_${DB}.md5sum

            echo -n ", tar"

            tar --remove-files -zcf ${BASE}_${DB}.tgz ${BASE}_${DB}.*

            echo ", md5"

            md5sum -b ${BASE}_${DB}.tgz >${BASE}_${DB}.md5sum

            fi

            done < ${TMPNAME}

            rm -f ${TMPNAME}

            cd ${CURDIR}

            echo "Done."

            }

            # Call for all your servers

            Backup localhost

            Backup my.othersever.com

            02 Jun 2004 05:33 oberger

            It does what it says and is quite cool
            Very interesting tool, that does what it says and provides detailed logs of what was done

            Screenshot

            Project Spotlight

            OpenStack4j

            A Fluent OpenStack client API for Java.

            Screenshot

            Project Spotlight

            TurnKey TWiki Appliance

            A TWiki appliance that is easy to use and lightweight.