Migrating from MoinMoin to DokuWiki

On our webserver, we run a wiki for tracking various administrative bits. Today, we migrated it from MoinMoin 1.3 to DokuWiki. This was not entirely trivial but at the same time not that difficult. The following method doesn’t preserve history, users or attachments, but seems to basically work. The handling of categories could probably use a little work though.

  1. First, find the latest revision of the files and move them to the right place. In sh, this is expressed roughly as:

    MOINWIKI=XXX
    DOKUWIKI=YYY
    
    cd $MOINWIKI/main/data/pages
    for i in *; do
        r=$(ls -tr $i/revisions 2>/dev/null | tail -1);
        if [ "$r" ]; then
            cp $i/revisions/$r $DOKUWIKI/data/pages/$i.txt;
        fi
    done
    
  2. Next, you’ll need to handle any categories manually and move them into subdirectories for namespaces. This could probably be automated by splitting based on the (2f)s in the filenames.

  3. Since DokuWiki prefers lowercase filenames, go ahead and lowercase all the filenames, e.g.:

    rename '$_ = lc($_)' *.txt
    

    using this handy perl script. You can repeat this for each namespace/category.

  4. Hack the markup. Create the following migrate.pl script:

    #!/usr/bin/perl -ni.bak
    
    BEGIN { $readblank = 0; }
    
    $readblank = 1 if /^$/;
    
    # Fix line-endings for Unix
    $//;
    
    # Ignore all pragmas
    next if !$readblank and /^#/;
    
    # Fix different a href linking styles
    s/\[(http:\S+)\s+(.*?)]/[\[$1|$2\]]/g;
    
    # Fix lists that aren't indented enough
    s/^ \*/  \*/;
    
    # Fix ordered lists
    s/^(\s+)\d+\./$1-/;
    
    # Fix code blocks
    s/^{{{$/<code>/;
    s/^}}}$/<\/code>/;
    
    # Fix monospace/code text
    s/`/''/g;
    s/{{{(.*?)}}}/''$1''/g;
    
    # Fix headers
    s/^= (.*) =$/====== $1 ======/g;
    s/^== (.*) ==$/===== $1 =====/g;
    s/^=== (.*) ===$/==== $1 ====/g;
    
    print;
    

    and run it on each file (find . -name "*.txt" | xargs -n 1 perl migrate.pl).

  5. Make sure your local.php sets $conf['camelcase'] = 1.

  6. You’ll need to move your attachments from the various attachments subdirectories and move them into DokuWiki’s media subdirectory and fix up the links.

That’s it!

  • Share/Bookmark

3 Comments

  1. Posted 18 April 2006 at 16:54 | Permalink

    Small hint: For step 3 you may want to use my sanity.pl script with the -e and -l switches…

  2. jan
    Posted 6 November 2007 at 05:57 | Permalink

    script improvement

    Fix headers

    next if s/^= (.) =$/====== $1 ======/g && print; next if s/^== (.) ==$/===== $1 =====/g && print; next if s/^=== (.) ===$/==== $1 ====/g && print; next if s/^==== (.) ====$/=== $1 ===/g && print; next if s/^===== (.) =====$/== $1 ==/g && print; next if s/^====== (.) ======$/= $1 =/g && print;

  3. Posted 24 May 2008 at 14:54 | Permalink

    What was the reason for migrating from MoinMoin to DokuWiki? I have to pick a wiki for Our company and am curious if We would need to eventually need to do something similar.

Post a Comment

Your email is never shared. Required fields are marked *

*
*