boysenberry has asked for the wisdom of the Perl Monks concerning the following question:

Doesn anyone know of perl modules that can backup mysql databases using DBI:: and DBD::mysql (or some other way) without having shell access?

I can log on to an external mysql server and have full privledges, but I don't have shell or script access on the server.

  • Comment on Looking for module(s) that will backup mysql databases using DBI & DBD::mysql

Replies are listed 'Best First'.
Re: Looking for module(s) that will backup mysql databases using DBI & DBD::mysql
by hubb0r (Pilgrim) on Aug 26, 2005 at 23:22 UTC
    Mysqlhotcopy should do what you want, and it can be run remotely.
      >and it can be run remotely.
      really? on the docu page it sez:
      but it can be run only on the same machine where the database director +ies are located.
      ..but maybe that meant the /target/ directories (backing up TO) - i don't know

      at any rate - i don't see how this is any better than mysqldump which is what i've employed for this purpose in the past
      http://dev.mysql.com/doc/mysql/en/mysqldump.html

      but while he says he doesn't have shell or script access on the db machine, mysqldump can be run remotely (too?)

      here's the command i use to backup my database:
      mysqldump -acQ -h "$cfg{db_host}" -u "$cfg{db_user}" --password="$cfg{ +db_pass}" --add-drop-table --allow-keywords "$cfg{db_prod}" > $cfg{cg +i_root}/$cfg{backups}/$cfg{prod}_$block_date.sql
      and here's the command i use in a "staging" script (ahem, a few lines below the above), to copy my beta database into the production database:
      mysqldump -h "$cfg{db_host}" -u "$cfg{db_user}" --password="$cfg{db_pa +ss}" -acQ --add-drop-table --allow-keywords "$cfg{db_dev}" | mysql -s + -D "$cfg{db_prod}" -h "$cfg{db_host}" -u "$cfg{db_user}" --password= +"$cfg{db_pass}"
      it should be noted too that i'm in an identical situation: $cfg{db_host} is a machine i don't have script or shell access on.
        you're right... you need local access to the machine to run the mysqlhotcopy script. It logs in to the mysql server and locks everything, then copies all of the relevant data files locally on the machine to somewhere else. It can transfer the data to some other machine, but you need to run mysqlhotcopy locally. Sorry for the confusion.
Re: Looking for module(s) that will backup mysql databases using DBI & DBD::mysql
by eXile (Priest) on Aug 27, 2005 at 04:48 UTC
    for completeness, there is also 'mysqldump' that can be used to make a backup of a mysql database over the mysql connection.

    And with the risk of completely getting off topic, you can also run mysqlservers in a slave-master replication setting so you have a 'hot backup' server ready in case you need one. I refer to the mysql documentation for how to set this type of thing up.

Re: Looking for module(s) that will backup mysql databases using DBI & DBD::mysql
by holdyourhorses (Monk) on Aug 27, 2005 at 07:59 UTC
Re: Looking for module(s) that will backup mysql databases using DBI & DBD::mysql
by shiza (Hermit) on Aug 26, 2005 at 23:56 UTC
    ..and it's written in Perl!

    "mysqlhotcopy is a Perl script that was originally written and contributed by Tim Bunce."