This shows you how to copy all the pages to text files. It’s a slow process.
To back up CommunityWiki, you probably want to use the “rsync” process described at CommunityWikiBackup instead – it’s much faster. Or is it better to use the “svn” process described at DecentralizedWiki ? We keep this page around because it’s a good example of a process that works on any Oddmuse wiki; the “rsync” and “svn” tools are faster but not set up on some Oddmuse wiki.
Note that your filesystem needs to be able to save UTF-8 filenames, and it needs to distinguish case (this is problematic for the default Windows and Mac OS X filesystems).
Here’s how to copy your pages to the current directory:
for p in `curl "http://www.communitywiki.org/en?action=index;raw=1"`; do sleep 5 curl -o $p "http://www.communitywiki.org/en/raw/$p" done
The first curl call fetches all the pages from this wiki as plain text, one page name per line. Then the second curl is called for every page, downloading it. The call to sleep makes sure you’re not overloading the wiki.
You can use similar commands to merge pages from other wikis into the current directory – as long as their pagenames don’t overlap.
You can also copy only a selected few of these pages. Instead of using the action=index URL, prepare a list of pages manually, listing all the page names you want, one page per line. Then read the pagenames from that file:
for p in `cat PAGELIST`; do sleep 5 curl -o $p "http://www.communitywiki.org/en/raw/$p" done
Or use matching pagenames to create your page list:
curl -o PAGELIST "http://www.communitywiki.org/cw?action=index;raw=1;match=wiki"
Or use a search result to create your page list:
curl -o PAGELIST "http://www.communitywiki.org/cw?search=creativ;raw=1;context=0"
Here’s how to install the pages in the current directory onto an existing Oddmuse wiki. Don’t forget to change the target URL!
for p in *; do echo $p curl -F question=1 -F title=$p -F text="<$p" "http://www.emacswiki.org/cgi-bin/test" sleep 5 done
The echo statement is just to give you some feedback, because curl doesn’t print any output when using the -F option.
The question parameter bypasses the Oddmuse:QuestionAsker Extension, if you have it installed. You should, if you haven’t.