# Using activerecord to copy records from one database to anot

**URL:** <https://www.ruby-forum.com/t/using-activerecord-to-copy-records-from-one-database-to-anot/87192>\
**Category:** Rails\
**Created:** [February 28, 2007, 8:07pm UTC](https://www.ruby-forum.com/t/using-activerecord-to-copy-records-from-one-database-to-anot/87192 "2007-02-28T20:07:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@dan](https://www.ruby-forum.com/u/dan)\
**Post date:** [February 28, 2007, 8:07pm UTC](https://www.ruby-forum.com/t/using-activerecord-to-copy-records-from-one-database-to-anot/87192/1 "2007-02-28T20:07:47Z")

</div>

Hello,

Our DBA accidentally restored a database resulting in a loss of all  
data from the weekend. The problem is that it was discovered after a  
day’s worth of data entry, resulting in the same record keys  
identifying different records.

The data is quite complex with a larger number of relationships. I  
have been thinking about using ActiveRecord to pull the missing days  
worth of data out of a back up and insert it into the production  
database.

My concern is that all of the keys would need to be cleared from  
objects retrieved from the backup before they were inserted into the  
production database.

Is there an easy way to do this? Think I should just use raw SQL  
instead?

Thanks.
