edit · print · PDF

Please note that all the SIEpedia's articles address specific issues or questions raised by IAC users, so they do not attempt to be rigorous or exhaustive, and may or may not be useful or applicable in different or more general contexts.

How to make a backup copy of your PmWiki

As you certainly know, the dynamically created content in Pmwiki (and other wikis as well) is stored only in the Web server, to which we have only partial access. In fact, we can easily distribute files from the test server (rives) to the production server (goya or www.iac.es), but we do not know of any tool which allow somebody to make a copy of all their files (including those dynamically created) from the server to some local directory.

Fortunately, for PmWiki a script is available to archive all files in selected directories (such as wiki.d, pub, cookbook etc.)in a zip file, which can then be downloaded and

Here we explain step by step what to do

Download and modify backup script

  • Go to Web page: http://nicolas.raibaut.free.fr/wiki/Nico/BackupPmWiki and download the backup_pmwiki.txt script.
  • Rename it to .php and save it into the cookbook directory in your pmwiki root directory (that is, the directory containing local/, wiki.d/ etc.) in the development server (that is, in /net/rives/data/www ... or /net/rives/si/www ...).
  • Edit the script, and if you wish modify it. We just removed the reference to the date in the output filename, by modifying the line below:
    # Define BackupFile name, with date format and backup format
    //SDV($BackupFile, $WikiTitle."_full_".date($DateFormat).$BackupFormat); (original)
    SDV($BackupFile, $WikiTitle."_full_".$BackupFormat); // (modified)
    This to avoid to create multiple backup files, each with a different date, in the server.
  • The default format is ".zip" (use command unzip to expand it). We tried to set it to tgz, and while the script did create a file with extension ".tgz", it still was in zip format ... However, feel free to experiment with it.
  • You can add or remove directories from the default list.

Create directory for backup

  • Go to your root pmwiki directory.
  • Create backup directory: mkdir backup
  • Set full read/write/execute permission: chmod 777 backup

Set the script to work for a specific page

  • It is recommended that the script only be launched from a dedicated page. So we use the per group/per page PmWiki customization (read http://www.pmwiki.org/wiki/PmWiki/PerGroupCustomizations for details about this interesting feature) to achieve it.
  • Go to local/ directory, and create file Admin.BackupWiki.php with the following content:
    <?php if (!defined('PmWiki')) exit();
    //$BackupDir = '/mybackupdirectory/'; // defaults to '/backup/'
    // other parameters : see backup_pmwiki.php
  • Be careful, there must be no blanks or characters before "<?php".
  • Note that there is no need to actually create the Admin.BackupWiki page, as its only purpose is to allow execution of the backup script through the "?action=backup" flag.

Distribute to external server

  • Follow the instructions provided by your friendly Web administrators to copy the above files to the production web server.

Test it!

Automating it

We might want to make a daily copy of our PmWiki, and store all such copies in some directory in our scratch disk. We will use the curl and the cron commands to do this.

  • Curl is a powerful and versatile command line tool to do number of Web-related operations. It can be used to download or upload files, to fill and send Web forms, and for many many other things (see http://curl.haxx.se/ for details). For instance, we (the SIE) use it to quickly distribute files from rives to goya, without the cumbersome process of loading and manually filling in the Web form. How? With a simple shell script using the curl command, passing along the required data for the form fields (Interested? get in touch with us).
  • A simple script to create and download the pmwiki-backup file may look like this (actual example for our SIEwiki):
    #!/bin/csh -f
    # Create backup file:
    curl "http://goya/SIE/wiki/pmwiki.php?n=Admin.BackupWiki?action=backup"
    # Download to guinda:
    cd /net/guinda/scratch1/invweb/backup_SIEwiki/
    wget http://goya/SIE/wiki/backup/SIEWiki_full_.zip
    # Rename with current date:
    set fecha=`date +'20h-%d'`
    \mv SIEWiki_full_.zip SIEWiki_${fecha}.zip
  • This script can be added to a cron job, and thus executed daily or with some other periodicity.
edit · print · PDF
Page last modified on April 07, 2008, at 10:05 PM