3
migration from moin 1.3 < patch-xxx to moin 1.3 >= patch-xxx
5
* we forgot to handle edit-lock files. We simply delete them now.
6
* we convert attachment names to utf-8
8
Steps for a successful migration:
10
1. Stop your wiki and make a backup of old data and code
12
2. Make a copy of the wiki's "data" directory to your working dir
14
3. make sure that from_encoding and to_encoding matches your needs (see
15
beginning of script below and config.charset in moin_config.py) and
16
run python2.3 12_to_13_mig10.py from your working dir
18
4. If there was no error, you will find:
19
data.pre-mig10 - the script renames your data directory copy to that name
20
data - converted data dir
22
5. Verify conversion results (number of pages, size of logs, attachments,
23
number of backup copies) - everything should be reasonable before
26
6. Copy additional files from data.pre-mig10 to data (maybe intermaps, logs,
27
etc.). Be aware that the file contents AND file names of wiki content
28
may have changed, so DO NOT copy the files inside the cache/ directory,
29
let the wiki refill it.
31
7. Replace the data directory your wiki uses with the data directory
32
you created by previous steps. DO NOT simply copy the converted stuff
33
into the original or you will duplicate pages and create chaos!
35
8. Test it - if something has gone wrong, you still have your backup.
38
@copyright: 2005 Thomas Waldmann
39
@license: GPL, see COPYING for details
42
from_encoding = 'iso8859-1'
43
#from_encoding = 'utf-8'
47
import os, os.path, sys, urllib
49
# Insert THIS moin dir first into sys path, or you would run another
51
sys.path.insert(0, '../../..')
52
from MoinMoin import wikiutil
54
from migutil import opj, listdir, copy_file, move_file, copy_dir
57
""" this removes edit-lock files from the pagedirs and
58
converts attachment filenames
60
pagesdir = opj(dir_to, 'pages')
61
pagelist = listdir(pagesdir)
62
for pagename in pagelist:
63
pagedir = opj(pagesdir, pagename)
64
editlock = opj(pagedir, 'edit-lock')
70
attachdir = os.path.join(pagedir, 'attachments')
71
for root, dirs, files in os.walk(attachdir):
75
except UnicodeDecodeError:
76
fnew = f.decode(from_encoding).encode(to_encoding)
77
os.rename(os.path.join(root,f), os.path.join(root, fnew))
78
print 'renamed', f, '\n ->', fnew, ' in dir:', root
81
origdir = 'data.pre-mig10'
84
# Backup original dir and create new empty dir
86
os.rename(destdir, origdir)
88
print "You need to be in the directory where your copy of the 'data' directory is located."
91
copy_dir(origdir, destdir)