Initial commit
[clearscm.git] / bin / backup
1 #!/bin/bash
2 ################################################################################
3 #
4 # File:         $RCSfile: backup,v $
5 # Revision:     $Revision: 1.7 $
6 # Description:  This script backs up the system in a consistent way
7 # Author:       Andrew@DeFaria.com
8 # Created:      Tue Jul 27 15:00:11 PDT 2004
9 # Modified:     $Date: 2011/05/26 06:17:20 $
10 # Language:     Bash
11 #
12 # (c) Copyright 2000-2005, ClearSCM, Inc., all rights reserved.
13 #
14 ################################################################################
15 # Full Backup
16 backup=/sbin/dump
17 dumppath=/backup
18 files2backup=/
19
20 if [ -f /etc/dump.excludes ]; then
21   excludes="-E /etc/dump.excludes"
22 else
23   excludes=""
24 fi
25
26 if [ $(id -u) -ne 0 ]; then
27   echo "You must be root to backup"
28   exit 1
29 fi
30
31 function usage {
32   type="$1"
33
34   echo "Usage: backup <full | incremental>"
35   exit 1
36 } # usage
37
38 type="$1"
39 host=$(hostname)
40
41 host=$(hostname)
42
43 if [ "$type" = "full" ]; then
44   rm -f $dumppath/$host.$type.backup
45   rm -f $dumppath/$host.$type.backup.log
46   rm -f $dumppath/$host.$type.list  
47   level=0
48 elif [ "$type" = "incremental" ]; then
49   level=1
50 else
51   usage $type
52 fi
53
54 log=$dumppath/$host.$type.backup.log
55
56 $backup -$level\
57   -A $dumppath/$host.$type.list\
58   -f $dumppath/$host.$type.backup\
59   -z\
60   $excludes\
61   -u $files2backup > $log 2>&1