MySQL backup using rails

Hi,

I want to backup and restore my database using Ruby code.

Does any one can give an idea of how to do this.

My requirement is the Admin who is logged in to the application
should be able to create a backup of the database available.

How can i do this.

Thanks
Jagan

Hi,

Hi,

I want to backup and restore my database using Ruby code.

Does any one can give an idea of how to do this.

You can use “mysqldump” [1] console program for database backup. (execute it with right arguments)

For import you can use “mysqlimport” [2].

My requirement is the Admin who is logged in to the application
should be able to create a backup of the database available.

When click to backup button, you execute mysqldump program to backup
and save file to “public/backups/#{date…}”. It is better you save
some information about backup to “backups” table.

For import, list files in “public/backups” (if you use “backups” table
it is easier to list records). When selected some file, you send it to
mysqlimport as a argument.

Links:

[1] http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html

[2] http://dev.mysql.com/doc/refman/5.0/en/mysqlimport.html

Regards,

Murat

Since this seems to be for an online 'hot' backup. Careful attention
needs to be paid to getting a consistent backup in the face of
concurrency.

I think that this means a little study of the implications of options like:

   --lock-tables
  --lock-all-tables
and
  --single-transaction

on mysqldump. Note also that things change depending on wheter the
table is InnoDB, MyIsam or whatever.