source: tools/www-backup.sh@ 343

Last change on this file since 343 was 343, checked in by Rick van der Zwet, 13 years ago

Create new backup environment.

  • Property svn:executable set to *
File size: 877 bytes
RevLine 
[343]1#!/bin/sh
2#
3# $Id$
4#
5# Backup WebDAV and Subversion and Wiki
6#
7# Rick van der Zwet <info@rickvanderzwet.nl>
8
9
10FQDN=${1:-tyan.wirelessleiden.nl}
11HOSTID=`echo $FQDN | awk -F "." '{print $1}'`
12
13BACKUP_USER=${BACKUP_USER:-${2:-backup}}
14SSH_KEY=${3:-/root/.ssh/backup.key}
15DIRS=${4:-"drupal wiki webfolder svn"}
16
17EXCLUDES=`dirname $0`/excludes
18
19DELETEROOT="/usr/backup/$HOSTID/wwwbackup/old"
20MIRRORROOT="/usr/backup/$HOSTID/wwwbackup/current"
21
22BACKUPDIR=$DELETEROOT/`date '+%Y/%M/%d'`
23OPTS="--force --ignore-errors --delete-excluded
24 --delete --backup --backup-dir=$BACKUPDIR --archive"
25
26
27if [ -r $EXCLUDES ]; then
28 OPTS="$OPTS --exclude-from=$EXCLUDES"
29fi
30
31
32for DIR in $DIRS; do
33 TARGET=$MIRRORROOT/$DIR
34 SOURCE=/usr/local/www/$DIR
35 mkdir -p $TARGET $BACKUPDIR
36
37 # now the actual transfer
38 rsync --rsh="ssh -i $SSH_KEY -l $BACKUP_USER" $OPTS $FQDN:$SOURCE $TARGET
39done
Note: See TracBrowser for help on using the repository browser.