1#!/bin/bash
2#
3# A sample script to backup the whole wiki site to <wiki>/../backup
4# Modify or copy this to match your needs.
5#
6time (
7time=`date +%Y%m%d-%H%M%S`
8file=`readlink -f "$0"`
9dir=`dirname "$file"`
10
11wiki_dir=$(readlink -f "$dir/../../../../")
12wiki_base=$(basename "$wiki_dir")
13backup_dir=$(readlink -f "$wiki_dir/../backup")
14backup_file="$backup_dir/$wiki_base-$time"
15
16if [ ! -d "$backup_dir" ]; then
17    mkdir -p "$backup_dir" &&
18    cat >"$backup_dir/.htaccess" <<EOL
19Order allow,deny
20Deny from all
21Satisfy all
22EOL
23fi &&
24
25tar --exclude=data/cache/[0-9a-f] --exclude=data/locks/[^_]* --exclude=data/tmp/* -jcvf "$backup_file.tar.bz2" -C $(dirname "$wiki_dir") $(basename "$wiki_dir")
26)