4 # Copyright (C) 2001 Eugenio Diaz <getnito@yahoo.com>
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above
13 # copyright notice, this list of conditions and the following
14 # disclaimer in the documentation and/or other materials provided
15 # with the distribution.
16 # 3. Neither the name of the University nor the names of its
17 # contributors may be used to endorse or promote products derived
18 # from this software without specific prior written permission.
20 # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS
24 # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 # This script will redirect the backup directory to implement desired
38 # We will use just a seven day format where we just move a link that
39 # represents the backup directory, to point to the day of the week.
44 # Configuration Parameters
47 if [ "$1" = "monthly" ]; then
53 BACKUPPART=${BACKUPPART:-"/backup"}
54 BACKUPDIR=${BACKUPDIR:-"current"}
56 echo "### Start of Backup Rotation ###"
57 echo "Using backup partition: $BACKUPPART"
59 echo -n "Remounting backup partition read-write ... "
60 if ( mount $BACKUPPART -o remount,rw &> /dev/null ) then
64 echo "There were problems remounting $BACKUPPART in read-write mode!"
65 echo "Rotation not made!"
66 echo "### End of Backup Rotation ###"
70 echo -n "Checking that no directory named \"$BACKUPDIR\" exists ... "
71 if [ -d $BACKUPPART/$BACKUPDIR -a ! -L $BACKUPPART/$BACKUPDIR ]; then
73 echo "Directory \"$BACKUPDIR\" exists. Can't create link!"
74 echo "Rotation not made!"
76 echo -n "Remounting backup partition read-only ... "
77 if ( mount $BACKUPPART -o remount,ro &> /dev/null ) then
81 echo "There were problems remounting $BACKUPPART in read-only mode!"
82 echo "### End of Backup Rotation ###"
85 echo "### End of Backup Rotation ###"
93 echo -n "Creating link: $BACKUPDIR --> $REALDIR ... "
94 if ( ln -snf $REALDIR $BACKUPDIR &> /dev/null ) then
98 echo "There were problems creating link!"
99 echo "Rotation not made!"
101 echo -n "Remounting backup partition read-only ... "
102 if ( mount $BACKUPPART -o remount,ro &> /dev/null ) then
106 echo "There were problems remounting $BACKUPPART in read-only mode!"
107 echo "### End of Backup Rotation ###"
110 echo "### End of Backup Rotation ###"
114 echo -n "Remounting backup partition read-only ... "
115 if ( mount $BACKUPPART -o remount,ro &> /dev/null ) then
119 echo "There were problems remounting $BACKUPPART in read-only mode!"
120 echo "### End of Backup Rotation ###"
123 echo "### End of Backup Rotation ###"