Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 2049  / 1 Year ago, sun, february 26, 2023, 7:13:30

Due to a system crash, I had to do a fresh install on a new computer. Luckily my harddisk was not affected -- but unfortunately the "good old 8.04" didn't want to boot from it on the new system...



So with 12.04 installed on a fresh harddisk, I copied all evolution folders from the old disk to the corresponding locations (~/.evolution plus ~/.gconf/apps/evolution -- the old Evo on 8.04 had no ~/.local/share/evolution), and started the app. The migration assistant popped up, and I went through -- but in the end, only one of my "accounts" in each category was migrated and available: local mail, one of 4 IMAP accounts (though data of all 4 accounts where moved to ~/.local/share/evolution), one of 4 address books, and so on.



Not a big deal for the IMAP stuff, as I just had to configure it (data are stored on the server in this case). But how can I get my addressbooks back? As described above, starting the "old installation" to export those data is not an option, as the old system cannot be started anymore. Is there a way to fire the migration assistant for a given dataset (in my case: tell it to just migrate-and-import a single specified addressbook)?


More From » 12.04

 Answers
4

Digging in a bit deeper, I figured two things: While the new database format is SQLite3, the old was some binary storing VCARDs which where clearly readable. So I came up with a small PHP snippet:



#!/usr/bin/php
<?php
# -=[ UserConf ]=-
$evodb = 'addressbook.db'; // (path and) name to the old address database
$name = 'business'; // name of the address book (used as filename)
$separate_vcards = FALSE; // if TRUE, each VCARD will go to a separate file

#-=[ Do not touch below lines ]=-
$re_vcard = '!(BEGIN:VCARD.*?END:VCARD)!ims';

$evo = file_get_contents($evodb);
preg_match_all($re_vcard,$evo,$vcards);
$cards = count($vcards[1]);
$new = '';
for ($i=0;$i<$cards;++$i) {
if ($separate_vcards) {
file_put_contents("${name}_${i}.vcf",$vcards[1][$i]);
} else {
$new .= $vcards[1][$i] . "

";
}
}
if (!$separate_vcards) file_put_contents("${name}.vcf",$new);
?>


This is not 100% perfect, but better than losing all those data. The script runs through the old-style database, and tries to fetch all VCARDs stored there. Those are either exported to separate files (each VCARD in one file, if $separate_vcards = TRUE), or to one collection (otherwise).



As those are supposed to be plain-text files, one can check them and correct them easily (line-breaks, binary garbage) -- and finally using Evolutions Import-Feature (found in the "File" menu) to import the data ("single file") into an existing addressbook (create an empty one before if you want a new addressbook).



For me this restored about 90% of my addresses fine. For the remaining 10%, some where mixed-up or broken (remember, even the old format was binary -- and the snippet just works in "ASCII mode").



Hope this helps somebody else (if so, don't forget to up-vote this solution).


[#37882] Monday, February 27, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
laceanz

Total Points: 86
Total Questions: 113
Total Answers: 104

Location: Australia
Member since Thu, Jan 26, 2023
1 Year ago
;