Summary: Export the content of PmWiki-formatted page files in a zip archive
Version: 20200319a
Prerequisites: PHP 5.2 or more recent
Status: Beta
Maintainer: Petko
License: GNU GPLv3+
Users: (view? / edit)
Discussion: ZipExport-Talk?

Export the content of PmWiki-formatted page files in a zip archive


This recipe allows to download the most recent version of a number of PmWiki page files in a ZIP archive. The page files can be placed in the wiki.d directory on another PmWiki installation and will be recognized as existing pages.

The recipe allows the export from any kind of PageStore class, including SQLite, PerGroupSubDirectories and others, and will output files that are usable in the default PmWiki PageStore class.

As of March 2020, the exported pages do not include the page histories, and by default the personal information of the last editor is removed (name, IP address).


Place zipexport.phpΔ in your pmwiki/cookbook directory and add this to your local/config.php:

  if($action == 'zipexport') {
    $ZipExport['WhiteListPages'] = 'Main.*,PmWiki*.*'; # SEE CONFIG SECTION


The following variables can be configured before the include_once(...) line:

  • $HandleAuth['zipexport'] = 'edit'; # What permissions are required for creating and downloading the archive (default 'read'). Note that this concerns the creation of the ZIP archive; the visitor also needs to have 'read' permissions for every individual page in the download specification.
  • $ZipExport['WhiteListPages'] = 'Main.*,PmWiki*.*'; # Which pages would be possible to export. By default, this is limited to the PmWiki documentation ('PmWiki*.*'). You need to add here the page patterns that your visitors will be allowed to request and download. The patterns are similar to the name= parameter used in PageLists, where * means any character, ? means exactly one character, individual patterns are separated with commas, and if the pattern starts with a minus, then pages that match it are excluded. For example, 'Main.*,Site.*,-*-Talk' allows the export of any page or pages in the Main or Site groups, except those that end with "-Talk".


The recipe is enabled on this page with the following whitelist:

  $ZipExport['WhiteListPages'] = 'Main.*,PmWiki*.*,Cookbook.*,-*-Talk,-*-Users'; 

In a wiki page, create a direct link to download the pages:

* [[ZipExport?action=zipexport&group=PmWikiDe | Get all pages in PmWikiDe/]]
* [[ZipExport?action=zipexport&link=PmWiki.DocumentationIndex | Get all pages linking back to DocumentationIndex]]
* [[ZipExport?action=zipexport&trail=PmWiki.DocumentationIndex | Get all pages from the trail at DocumentationIndex]]
* [[ZipExport?action=zipexport&trail=PmWiki.Variables | Get all pages from the trail at Variables]]
* [[ZipExport?action=zipexport&group=Cookbook&link=Profiles.Petko | Get all Cookbook pages that link back to Profiles.Petko]]


The full page text content is exported if the visitor has 'read' permissions. That means anything hidden in conditionals will possibly be readable, see PmWiki:ConditionalMarkup for the security implications.

To do / some day / maybe

If there is interest/funding:

  • Allow the export of a partial or full page history, with or without the author names/IP addresses.

Change log / Release notes

  • 20200319a Fix a bug where the current page is not included in the output.
  • 20200319 First public release, ready to be tested.

An early version of the recipe was written in 2009 and completely rewritten in 2020 with the PHP core ZipArchive functions, and with the WhiteListPages patterns.

See also

Cookbook /
BackupHTMLZip  Export your wiki to static HTML then optionally compress/zip it (Experimental)
PrintGroup  Export WikiGroup pages to one large HTML file, and/or to PDF (Experimental)
SiteDump  creates a .tar.gz file of the complete site for download (stable)
PmWiki /
PageLists  Searching and listing pages by multiple criteria with templated output



See discussion at ZipExport-Talk?

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.