Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tech:others:dokuwiki_backup [2014/11/15 09:13] (current)
Line 1: Line 1:
 +====== Dokuwiki backup script ======
 +Script to backup dokuwiki. ​ Include it in /​etc/​cron.daily. ​ Update the relevant file locations.
 +<file bash dokuwiki_backup>​
 +#!/bin/sh
 +#
 +# Dokuwiki backup script
 +#
 +NOW=$(date +"​%Y-%m-%d-%H-%M-%S"​)
 +#
 +DOKUWIKILOC="/​path/​to/​dokuwiki/​data"​
 +BACKUPLOC="/​path/​to/​backups"​
 +DOKUWIKIBACKUPLOC="​$BACKUPLOC/​dokuwiki"​
 +# Change to denote each wiki
 +DWBKPREFIX=dw18vb
 +
 +if [ ! -d $DOKUWIKIBACKUPLOC ]; then
 +  echo "​Backup directory $DOKUWIKIBACKUPLOC is missing."​
 +  exit 1
 +fi
 +
 +BACKUPFILE="​$DOKUWIKIBACKUPLOC/​${DWBKPREFIX}-backup-${NOW}.tar.gz"​
 +BACKUPLOG="​$DOKUWIKIBACKUPLOC/​${DWBKPREFIX}-backup-${NOW}.log"​
 +#
 +# Backup Data
 +tar -zcvf $BACKUPFILE -C $DOKUWIKILOC . > $BACKUPLOG 2>&1
 +chmod 600 $BACKUPFILE
 +#
 +# Delete old backups and logs
 +/​usr/​bin/​find $DOKUWIKIBACKUPLOC/​${DWBKPREFIX}-backup*.tar.gz -mtime +35 -exec rm {} \;
 +/​usr/​bin/​find $DOKUWIKIBACKUPLOC/​${DWBKPREFIX}-backup*.log -mtime +35 -exec rm {} \;
 +#
 +exit 0
 +</​file>​
  

QR Code
QR Code tech:others:dokuwiki_backup (generated for current page)