# Backup in rails

**URL:** <https://www.ruby-forum.com/t/backup-in-rails/118468>\
**Category:** Rails\
**Created:** [October 27, 2007, 10:38am UTC](https://www.ruby-forum.com/t/backup-in-rails/118468 "2007-10-27T10:38:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@rails](https://www.ruby-forum.com/u/rails)\
**Post date:** [October 27, 2007, 10:38am UTC](https://www.ruby-forum.com/t/backup-in-rails/118468/1 "2007-10-27T10:38:22Z")

</div>

Hello All,

I am trying to take a bacup of mysql database using rails appliction.

when i am executing the following command using irb i am able to take  
the backup

system(“mysqldump -u root -p -h cu-269 testdev \> d:/testl.sql”)

but when i am doing the same using a rails application i.e is thru web  
i am unable to backup the database.The page is hanging up with out any  
response.

My development environment is windows ,is this creating any problem

when i see the taskmanager-processes the mysqldump process is still  
executing

while in IRB the mysql process is stoping as soon as the backup  
operation is complete

am i missing out some thing that i need to do in rails

Thanks  
Prasad B

---

<div class="post-metadata">

**Author:** ![rails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@rails](https://www.ruby-forum.com/u/rails)\
**Post date:** [October 27, 2007, 11:07am UTC](https://www.ruby-forum.com/t/backup-in-rails/118468/2 "2007-10-27T11:07:03Z")

</div>

On 27 Oct 2007, at 09:37, rails wrote:

> am i missing out some thing that i need to do in rails

This is nothing to do with rails and everything to with mysql.To take  
a consistent dump with mysqldump you need to lock the db, which stops  
any other writes.  
Options:

-have a master & a slave and take database dumps off the slave  
-use something like innodb hot backup ([http://www.innodb.com/hot-](http://www.innodb.com/hot-)  
backup/)  
-use lvm snapshotting.

- perhaps others - I’m not expert.

Fred

---

<div class="post-metadata">

**Author:** ![rails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@rails](https://www.ruby-forum.com/u/rails)\
**Post date:** [October 27, 2007, 11:07am UTC](https://www.ruby-forum.com/t/backup-in-rails/118468/3 "2007-10-27T11:07:03Z")

</div>

This might be off-topic, but… Why would you create a dump of your  
database through a web request? Maybe use the request to tell the system  
to start a certain rake task, that, for example, dumps, compresses and  
packages up with the rest of your files, and places it somewhere ready  
to download, maybe behind some authorization system, firing an email at  
you when done.

I’d say, it’s a much cleaner approach than maybe having the request  
return a gziped dump directly.

Though I’m no ruby-master (pretty much on the other side of the gauge),  
so I’d have no clue how to build such a rake task. This is just an  
application design theory.

~Chris

El sï¿½b, 27-10-2007 a las 01:37 -0700, rails escribiï¿½:
