HomePage RecentChanges Status About

Backup

There are various ways of backing up your wiki. This page tells you how you can copy all the pages to text files using command line tools.

Your filesystem needs to be able to save UTF-8 filenames. If you use languages other than English, chances are that you might have trouble on Windows, for example.

Here’s how to copy your pages to the current directory:

  1. Make sure you use the bash shell or a compatible one
  2. Make sure you have curl installed
  3. Run it as follows, assuming your wiki is called NameOfYourWiki:
for p in `curl "http://www.campaignwiki.org/wiki/NameOfYourWiki?action=index;raw=1"`; do
  sleep 5
  curl -o $p "http://www.campaignwiki.org/wiki/NameOfYourWiki/raw/$p"
done

The curl fetches all the pages from your 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 this to merge pages from several wikis into one, 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. Create a text file and list all the page names you want, one page per line. Here’s an example where the text file is called PAGES.

for p in `cat PAGES`; do
  sleep 5
  curl -o $p "http://www.campaignwiki.org/wiki/NameOfYourWiki/raw/$p"
done

Or use a search to produce the subset:

for p in `curl "http://www.campaignwiki.org/wiki/NameOfYourWiki?search=CategoryHelp;raw=1;context=0"`; do
  sleep 5
  curl -o $p "http://www.campaignwiki.org/wiki/NameOfYourWiki/raw/$p"
done

Restoring a Backup

Here’s how to restore your wiki from pages in the current directory:

for p in *; do
  echo $p
  curl -F question=1 -F title=$p -F text="<$p" "http://www.campaignwiki.org/wiki/NameOfYourWiki" 
  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.

Huh?

Talk to me if the instructions above are utterly confusing. I’m sure we’ll figure something out. Some sort of zip file download or whatever. Since I don’t need it for myself, I haven’t worked on that. :) – Alex