[rt-users] Merging divergent databases
Tim Cutts
tjrc at sanger.ac.uk
Thu Apr 26 05:27:08 EDT 2012
On 26 Apr 2012, at 00:54, Phillip Frost wrote:
> I recently experienced a hardware failure that required that I restore the database from a backup that was a few days old. I was later able to recover the database at the time of the failure, but not until some new tickets had been created and others modified.
>
> Is there some clever way I can query the recovered database for everything that changed since the failure, and then merge it into the live database, which is missing those changes? The difference is not a whole lot, so even a somewhat manual process would be better than nothing.
Oooh, nasty. I feel for you! I think you could write scripts to retrieve tickets from one database and merge them into the other, although you'd have to allow the tickets and transactions to have a different id once transferred.
The logic of the script would have to be something along the lines of:
# script 1
connect to source_rt;
search for tickets to transfer;
foreach found ticket {
dump ticket basics;
dump ticket requestors, owner, watchers;
foreach transaction {
dump transaction;
foreach attachment {
dump attachment;
}
}
}
# script 2
connect to dest_rt;
open dump file;
foreach ticket in dump file {
create a new ticket object in dest_rt;
populate it with basics from ticket (not the ID, obviously);
set watchers, requestor etc;
foreach transaction on the ticket in the dump file {
create a new transaction object in distort;
populate it;
foreach attachment on the transaction {
create an attachment object in the database;
populate it;
}
}
}
You can probably fairly easily lift the appropriate bits of code from the main RT sources.
Regards,
Tim
--
The Wellcome Trust Sanger Institute is operated by Genome Research
Limited, a charity registered in England with number 1021457 and a
company registered in England with number 2742969, whose registered
office is 215 Euston Road, London, NW1 2BE.
More information about the rt-users
mailing list