Back to index

moin  1.9.0~rc2
wikibackup.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 """
00003 This script gets all Pages from a wiki via xmlrpc and
00004 stores them into a backup file. We use wiki rpc v2 here.
00005 
00006 Important note:
00007 
00008 This script ONLY handles the current versions of the wiki pages.
00009 
00010 It does NOT handle:
00011     * event or edit logs (page history)
00012     * old versions of pages
00013     * attachments
00014     * user account data
00015     * MoinMoin code or config running the wiki
00016 
00017 So this is definitely NOT a complete backup.
00018 
00019 GPL software, 2003-08-10 Thomas Waldmann
00020 """
00021 def run():
00022     import xmlrpclib
00023     from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
00024     from MoinMoin.util import pickle, PICKLE_PROTOCOL
00025 
00026     #user = "username"
00027     #password = "xxxxxxxx"
00028     #srctrans = BasicAuthTransport(user,password)
00029     #srcwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/__xmlrpc/?action=xmlrpc2", transport=srctrans)
00030     srcwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/?action=xmlrpc2")
00031 
00032     backup = {}
00033     allpages = srcwiki.getAllPages()
00034     for pagename in allpages:
00035         pagedata = srcwiki.getPage(pagename)
00036         print "Got %s." % pagename
00037         backup[pagename] = pagedata
00038 
00039     backupfile = open("wikibackup.pickle", "w")
00040     pickle.dump(backup, backupfile, PICKLE_PROTOCOL)
00041     backupfile.close()
00042 
00043 if __name__ == "__main__":
00044     run()
00045