Skip to content

DokuWiki Backup and Restore — File Backup, Incremental, and Automation Scripts

DodaTech Updated 2026-06-28 7 min read

In this tutorial, you'll learn how to backup and restore a DokuWiki installation, including full file backups, incremental backups, Git-based version control for wiki content, automation scripts, and disaster recovery procedures.

What You'll Learn

  • What needs to be backed up (and what does not)
  • Full file backup strategies
  • Incremental backups with rsync
  • Git-based version control for wiki content
  • Backup automation scripts
  • Restore procedures
  • Disaster recovery planning

Why It Matters

Backup is the most important maintenance task for any wiki. Unlike MediaWiki which requires database dumps, DokuWiki's flat-file architecture makes backup simpler — but it is still easy to get wrong. A proper backup Strategy ensures you can recover from hardware failure, accidental deletion, corruption, or security incidents with minimal data loss.

Real-World Use

A server hosting a company wiki suffers a disk failure. The last backup was 6 hours ago. The administrator restores the wiki on a new server: copies the data/ and conf/ directories from the backup to the new server, installs a fresh DokuWiki, sets file permissions, and restarts the web server. The wiki is back online within 30 minutes. The only data loss is 6 hours of edits.

Learning Path

flowchart LR
  A[API] --> B[Backup]
  B --> C[Upgrading]
  C --> D[Migration]
  D --> E[Performance]
  E --> F[Security]

What to Back Up

DokuWiki data is stored in files. You do not need to back up everything.

Required for Backup

Path Reason
data/ All user content, media, revisions, cache, index
conf/ Configuration, ACL rules, user accounts
lib/plugins/ Installed plugins (optional — can reinstall)
lib/tpl/ Installed templates (optional — can reinstall)

Optional for Backup

Path Reason
inc/ Core files — reobtain from DokuWiki download
vendor/ Dependencies — reinstall via Composer
bin/ CLI scripts — included in core download
data/
conf/
lib/plugins/ (if you have custom plugins)
lib/tpl/ (if you have custom templates)

Full File Backup

Simple Tar Backup

#!/bin/bash
# backup.sh - Full DokuWiki backup

WIKI_DIR="/var/www/html/wiki"
BACKUP_DIR="/var/backups/wiki"
DATE=$(date +%Y%m%d_%H%M%S)

# Create backup directory
mkdir -p "$BACKUP_DIR"

# Backup essential directories
tar -czf "$BACKUP_DIR/dokuwiki-backup-$DATE.tar.gz" \
    -C "$WIKI_DIR" \
    data/ \
    conf/ \
    lib/plugins/ \
    lib/tpl/

echo "Backup created: $BACKUP_DIR/dokuwiki-backup-$DATE.tar.gz"
echo "Size: $(du -h "$BACKUP_DIR/dokuwiki-backup-$DATE.tar.gz" | cut -f1)"

Backup with Rotation

#!/bin/bash
# backup-rotate.sh - Backup with 30-day retention

WIKI_DIR="/var/www/html/wiki"
BACKUP_DIR="/var/backups/wiki"
RETENTION_DAYS=30

DATE=$(date +%Y%m%d)

# Create backup
tar -czf "$BACKUP_DIR/wiki-$DATE.tar.gz" \
    -C "$WIKI_DIR" \
    data/ conf/ lib/plugins/ lib/tpl/

# Remove backups older than retention period
find "$BACKUP_DIR" -name "wiki-*.tar.gz" -mtime +$RETENTION_DAYS -delete

echo "Backup: wiki-$DATE.tar.gz"
echo "Old backups removed (retention: $RETENTION_DAYS days)"

Incremental Backup with rsync

rsync is ideal for frequent incremental backups — it only copies changed files.

Local Incremental Backup

#!/bin/bash
# incremental-backup.sh

WIKI_DIR="/var/www/html/wiki"
BACKUP_DIR="/mnt/backup/wiki"

# Sync data and conf directories
rsync -avz --delete \
    "$WIKI_DIR/data/" \
    "$BACKUP_DIR/data/"

rsync -avz --delete \
    "$WIKI_DIR/conf/" \
    "$BACKUP_DIR/conf/"

echo "Incremental backup completed."

Remote Backup via SSH

#!/bin/bash
# remote-backup.sh

rsync -avz --delete -e ssh \
    /var/www/html/wiki/data/ \
    user@backup-server:/backups/wiki/data/

rsync -avz --delete -e ssh \
    /var/www/html/wiki/conf/ \
    user@backup-server:/backups/wiki/conf/

Git-Based Version Control

Because DokuWiki pages are text files, you can version control them with Git.

Initialize Git Repository

cd /var/www/html/wiki

# Create .gitignore to exclude cache and temp files
cat > .gitignore << EOF
data/cache/
data/index/
data/locks/
data/tmp/
data/attic/
data/logs/
EOF

# Initialize repository
git init
git add data/pages/ data/meta/ conf/
git commit -m "Initial wiki content backup"

Automate Git Backup

#!/bin/bash
# git-backup.sh

WIKI_DIR="/var/www/html/wiki"
cd "$WIKI_DIR"

# Add and commit changes
git add -A
git commit -m "Wiki backup $(date +%Y-%m-%d_%H:%M:%S)"

# Push to remote if configured
git push origin main 2>/dev/null || true

Cron Job for Git Backup

# Run every 6 hours
0 */6 * * * /usr/local/bin/wiki-git-backup.sh

Restoration Procedures

Full Restore from Tar

#!/bin/bash
# restore.sh - Restore from tar backup

WIKI_DIR="/var/www/html/wiki"
BACKUP_FILE="/var/backups/wiki/dokuwiki-backup-20260628.tar.gz"

# Ensure DokuWiki is installed (or download fresh)
if [ ! -f "$WIKI_DIR/index.php" ]; then
    echo "DokuWiki not found. Downloading fresh copy..."
    wget -q -O /tmp/dokuwiki.tgz https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz
    tar -xzf /tmp/dokuwiki.tgz -C /tmp/
    mv /tmp/dokuwiki-*/ "$WIKI_DIR"
fi

# Restore backup
echo "Restoring backup: $BACKUP_FILE"
tar -xzf "$BACKUP_FILE" -C "$WIKI_DIR"

# Set permissions
chown -R www-data:www-data "$WIKI_DIR"
chmod -R 755 "$WIKI_DIR"
chmod -R 777 "$WIKI_DIR/data"
chmod -R 777 "$WIKI_DIR/conf"

echo "Restoration complete."
echo "Visit: http://yourserver/wiki/"

Partial Restore (Single Page)

# Restore a single page from backup
tar -xzf /var/backups/wiki/dokuwiki-backup-20260628.tar.gz \
    -C /tmp/restore/ \
    "data/pages/projects/roadmap.txt"

# Copy to wiki
cp /tmp/restore/data/pages/projects/roadmap.txt /var/www/html/wiki/data/pages/projects/roadmap.txt

Backup Verification

A backup is only useful if it can be restored. Verify regularly:

#!/bin/bash
# verify-backup.sh

BACKUP_FILE="/var/backups/wiki/dokuwiki-backup-20260628.tar.gz"
TEST_DIR="/tmp/verify-backup"

# Extract to temp directory
mkdir -p "$TEST_DIR"
tar -xzf "$BACKUP_FILE" -C "$TEST_DIR"

# Verify structure
echo "Verifying backup structure..."
if [ -d "$TEST_DIR/data/pages" ]; then
    PAGE_COUNT=$(find "$TEST_DIR/data/pages" -name "*.txt" | wc -l)
    echo "  Pages found: $PAGE_COUNT"
else
    echo "  ERROR: data/pages/ not found!"
fi

if [ -f "$TEST_DIR/conf/local.php" ]; then
    echo "  Configuration file found."
else
    echo "  ERROR: conf/local.php not found!"
fi

if [ -f "$TEST_DIR/conf/acl.auth.php" ]; then
    echo "  ACL file found."
else
    echo "  WARNING: acl.auth.php not found!"
fi

# Cleanup
rm -rf "$TEST_DIR"
echo "Verification complete."

Disaster Recovery Plan

Step 1: Assess Damage

  • Identify what is lost (pages, configuration, plugins, all)
  • Determine cause (hardware failure, accidental deletion, corruption, security breach)

Step 2: Prepare New Environment

  • Provision new server (or fix existing one)
  • Install PHP and web server
  • Download fresh DokuWiki

Step 3: Restore from Backup

  • Copy data/ and conf/ from most recent backup
  • Set correct file permissions
  • Verify configuration is intact

Step 4: Verify Restoration

  • Check that critical pages exist
  • Verify ACL rules work
  • Test user login
  • Run a test edit and save
  • Verify search index works (run indexer)

Step 5: Post-Recovery

  • Update DNS if server changed
  • Check for data loss since last backup
  • Review backup Process to improve RPO (Recovery Point Objective)

Common Mistakes

  1. Only backing up data/ without conf/: Without conf/, you lose ACL rules, user accounts, and all custom configuration. Backup both directories.
  2. Not verifying backups: A backup that cannot be restored is worthless. Test restoration quarterly at minimum.
  3. Keeping backups on the same server: If the server dies, on-server backups die with it. Store backups off-site.
  4. Not backing up plugin configurations: Plugin settings in conf/plugin/ are not in data/. Ensure your backup includes conf/.
  5. Ignoring .gitignore for cache directories: Adding cache, index, and lock files to Git bloats the repository and causes conflicts. Always exclude them.

Practice Questions

  1. What directories must be backed up to fully restore a DokuWiki installation?
  2. What is the advantage of Git-based backup over tar-based backup for wiki pages?
  3. What should you verify after restoring a DokuWiki from backup?
  4. Challenge: Design a complete backup strategy for a production DokuWiki. Requirements include: hourly incremental backups (rsync), daily full backups (tar), off-site storage, 30-day retention, automated verification, and documented restore procedures. Implement the strategy with scripts, test it on a staging environment, and perform a simulated disaster recovery where you delete the wiki data/ directory and restore from backup. Measure the recovery time and document each step.

FAQ

How often should I back up my DokuWiki?

For active wikis, backup at least daily. For critical wikis, consider hourly rsync plus daily tar. The right frequency depends on how much data you can afford to lose (Recovery Point Objective).

Can I use DokuWiki's built-in features for backup?

DokuWiki does not have a built-in backup feature. Backups must be done at the filesystem level using tar, rsync, or Git. Some plugins add backup functionality to the admin panel.

How do I backup only pages without configuration?

Backup only the data/pages/ directory. This excludes media files, revisions, configuration, and user accounts. Use with caution — restoring only pages means losing all settings.

What is the fastest way to restore a single page?

Copy the .txt file from the backup's data/pages/ directory to the wiki's data/pages/ directory. If you use Git, checkout the specific file from the commit before the unwanted change.

Should I include the attic directory in backups?

Yes and no. Include attic for full history preservation. Exclude it if you only care about current page content. Attic files can be several times larger than current page files.

Mini Project

Goal: Set up a complete backup and restore system.

  1. Create a backup script that: creates a tar archive of data/, conf/, and lib/plugins/, timestamps the filename, stores in /var/backups/wiki/, and keeps backups for 30 days
  2. Set up a Git repository for wiki content (data/pages/ and data/meta/)
  3. Configure rsync to sync data/ to a remote location (or a local backup drive)
  4. Verify each backup method works
  5. Simulate a disaster: delete the wiki data/ directory
  6. Restore from backup and verify the wiki works
  7. Document the complete backup and restore procedure

What's Next

Backups protect your data. Now learn how to upgrade DokuWiki safely to get new features and security fixes.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro