PDA

View Full Version : Automatic Backup of MySQL Databases


Robert
03-31-03, 04:23 PM
It's me again :love:

I am currently looking for another script.. I need a script that every month (or whenever I specify) ona cron job will backup a MySQL database (say like my Modernbill one) and zip it up (tar or zip) and email it to me.

Any ideas?

Thanks.

allan
03-31-03, 06:24 PM
I've used this script with good success:

http://members.lycos.co.uk/wipe_out/automysqlbackup/

It does not mail you the database, but I am sure it could be modified to do so -- unless you find a script that works for you :).

suppleSupport
03-31-03, 07:03 PM
This script will
- backup database
- e-mail backup
- remove backup

http://www.pixelbytes.com/mysqlbackup.zip

To use it, you'll need to make a cronjob with the following line:

php -q /home/yourusername/locationofscript/backup_db.php

(note: if you leave out the -q, then you'll receive one e-mail with the database and a separate e-mail with 2 useless echoed lines from php, some servers may send you an e-mail regardless)

Make sure to set the correct path name & filename of the backed up database or you're going to have your info flying all over the place. Also, this script can only be run via ssh or using a cronjob. It will give "Problem: 1" if accessed via a browser.

Robert
04-01-03, 06:27 AM
Elevation is just FULL of scripts huh? Thanks.. works like a charm.

suppleSupport
04-01-03, 07:01 AM
Originally posted by Robert:

Elevation is just FULL of scripts huh? Thanks.. works like a charm.

Heh, let me know if you need anything else.

interactive
04-01-03, 02:58 PM
Anyone know if mysqldump can dump a specific table?

suppleSupport
04-01-03, 05:02 PM
Originally posted by interactive:

Anyone know if mysqldump can dump a specific table?

Try selecting and dumping the specific table in PHPMyAdmin :)

interactive
04-01-03, 05:05 PM
Well I want to do it command line.

suppleSupport
04-01-03, 05:31 PM
mysqldump -u username -p dbname table1 > dump.sql

Replace:
username with the database username
dbname with the database name
table1 with the name of the table

You can add more tables like so:
mysqldump -u username -p dbname table1 table2 > dump.sql

interactive
04-01-03, 07:47 PM
Ahh thanks. Works like a charm (working on a auto back up script).

suppleSupport
04-01-03, 08:56 PM
NP