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.