# Possible to recover data from log/development.log files?

**URL:** <https://www.ruby-forum.com/t/possible-to-recover-data-from-log-development-log-files/190866>\
**Category:** Rails\
**Created:** [June 29, 2010, 3:14pm UTC](https://www.ruby-forum.com/t/possible-to-recover-data-from-log-development-log-files/190866 "2010-06-29T15:14:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![arvliet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee59a6/32.png) [@arvliet](https://www.ruby-forum.com/u/arvliet)\
**Post date:** [June 29, 2010, 3:14pm UTC](https://www.ruby-forum.com/t/possible-to-recover-data-from-log-development-log-files/190866/1 "2010-06-29T15:14:23Z")

</div>

Hey all. Seems I’ve found a bug in Rails db:migrate - maybe it is,  
maybe it isn’t. If possible - I’d appreciate some help recovering from  
it.

Apps, OS, etc.:  
MySQL: Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86\_64) using  
readline 5.1  
Rails: 2.3.8,  
OS: CentOS 5.4 updated as of this past weekend

Long story made short. I have a rails app in development mode with a  
significant amount of data. I created a couple migrations to add a  
couple columns and remove a couple more. After my first attempt to run  
the migrations, I realized I’d made a mistake and attempted to revert my  
changes with a ‘rake db:migrate VERSION=""’.

Mistake #1: Oops. I typed the name of my migration incorrectly, and it  
reverted to… wait for it… VERSION=“0”. That’s the “bug” part - (I  
don’t think) it shouldn’t be reverting to VERSION=“0” whenever it has an  
error or fails to find a migration… No, I didn’t have an environment  
variable VERSION=“0”.

Mistake #2: My bad - I didn’t back up the database before applying my  
changes. 05:30 AM + “meh - simple column change, what could happen…”  
=~ poop.onstick()

log/development.log seems like it contains all the INSERT INTO actions.  
(crosses fingers) Has anyone ever used the log file to recreate the  
database…? Am I missing something: is there a better way?

Any help, input, or ideas beyond “you should have backed up your DB”  
would really be appreciated.

Thanks,

Andrew V.  
1 403 667 3201 ©  
1 403 648 0627 (w)

---

<div class="post-metadata">

**Author:** ![arvliet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee59a6/32.png) [@arvliet](https://www.ruby-forum.com/u/arvliet)\
**Post date:** [June 29, 2010, 4:31pm UTC](https://www.ruby-forum.com/t/possible-to-recover-data-from-log-development-log-files/190866/2 "2010-06-29T16:31:01Z")

</div>

If you haven’t cleared out your log along the way, you should be able to  
parse through that and reconstruct your inserts.

I know I periodically ‘archive off’ my development.log  
(development.log.thru.20100617 anyone?) just so I have a record  
(especially when trying to diagnose issues).

---

<div class="post-metadata">

**Author:** ![arvliet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee59a6/32.png) [@arvliet](https://www.ruby-forum.com/u/arvliet)\
**Post date:** [June 30, 2010, 5:41pm UTC](https://www.ruby-forum.com/t/possible-to-recover-data-from-log-development-log-files/190866/3 "2010-06-30T17:41:56Z")

</div>

On Jun 29, 9:04 am, Andrew V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:\>

> Mistake #1: Oops. I typed the name of my migration incorrectly, and it  
> reverted to… wait for it… VERSION=“0”.

A little late, but another reason ‘the rails way’ encourages separate  
dev and production databases. You will get better performance running  
under production mode too

---

<div class="post-metadata">

**Author:** ![arvliet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee59a6/32.png) [@arvliet](https://www.ruby-forum.com/u/arvliet)\
**Post date:** [June 30, 2010, 4:53pm UTC](https://www.ruby-forum.com/t/possible-to-recover-data-from-log-development-log-files/190866/4 "2010-06-30T16:53:14Z")

</div>

Ar Chron wrote:

> If you haven’t cleared out your log along the way, you should be able to  
> parse through that and reconstruct your inserts.
> 
> I know I periodically ‘archive off’ my development.log  
> (development.log.thru.20100617 anyone?) just so I have a record  
> (especially when trying to diagnose issues).

Hmm. Perhaps instead of doing that, you should just put your  
development.log in version control? (I confess that I’ve never needed  
an archive such as you describe.)

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
