K
K
Konstantin Andreevich2010-09-25 21:31:58
MySQL
Konstantin Andreevich, 2010-09-25 21:31:58

How to automatically backup mysql?

I want to make mysql backups of some databases.
Something to automatically make a backup, send it to the mailbox and drop it on my computer.

How can it be implemented?

I have a free vps server.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
S
schursin, 2010-09-25
@schursin

I use the "cron + mysqldump + dropbox" bundle, as a result, automatic backup delivery to my machine and backup storage in the cloud.

K
Kirill Dlussky, 2010-09-27
@Dlussky

If such questions arise, then you should try
Sypex Dumper .
Of course, it is still beta, but it works very stable. Able to run from cron and upload files via ftp anywhere. Sending to soap can be implemented independently)

A
aazon, 2010-09-25
@aazon

try www.opennet.ru/dev/fsbackup/

A
agh, 2010-09-26
@agh

We go around all the database in a loop and remove the dumps

#!/bin/bash
USER="root"
PASSWORD="123123"
mkdir /var/backup/database/`date +%F`;
for DB in `mysql -u$USER -p$PASSWORD -N -e 'show databases' | awk '{print $1}'`; do
     mysqldump --user=$USER --host=$HOST --password=$PASSWORD ${DB} | gzip > /var/backup/database/`date +%F`/${DB}.sql.gz;
        echo "${DB} Backup";
    done
done

D
denv, 2010-09-26
@denv

not aesthetically pleasing =) but... ps (relevant for small databases, lock-tables locks the database during the dump process)
bash script, add to cron:

#!/bin/sh
mysqldump -u<LOGIN> -p<PASS>  --lock-tables --opt <BASENAME> > /sqldata/dump.sql
cd /sqldata/
tar -zcvf sqldata.tgz *.sql
perl sendtoemail.pl

The script requires the /sqldata folder, sendtoemail.pl is located in /sqldata.
contents of sendtoemail.pl, MIME::Lite is required:
#!/usr/bin/perl -w
use MIME::Lite;

$msg = MIME::Lite->new(
  From    => '[email protected]',
  To      => '[email protected]',
  Subject => 'sqldata.tgz MySQL backup!',
  Type    => 'text/plain',
  Data    => "Here are the MySQL database backups.");

$msg->attach(Type=>"application/x-tar",
             Path =>"/sqldata/sqldata.tgz",
             Filename =>"sqldata.tgz");

$msg->send;

A
amoresPerros, 2010-10-04
@amoresPerros

I can also recommend AutoMySQLBackup .
Configure and hang up in crowns. Able to send dumps to the mail - the MAILCONTENT = "files" parameter, mutt is required for work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question