Debian Codegraph @

examples/cron_dump_to_disk/backup_rotate

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 ###
4 # Copyright (C) 2001 Eugenio Diaz <[email protected]>
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 #
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.
19 #
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
31 # SUCH DAMAGE.
32 #
33 ##
34 #
35 # This script will redirect the backup directory to implement desired
36 # backup schedules.
37 #
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.
40 ##
41
42
43 #
44 # Configuration Parameters
45 #
46
47 if [scip-shell system . . `[`. "$1" = "monthly" ]; then
48 REALDIR="monthly"
49 else
50 REALDIR=`datescip-shell system . . date. +%A`
51 fi
52
53 BACKUPPART=${BACKUPPART:-"/backup"}
54 BACKUPDIR=${BACKUPDIR:-"current"}
55
56 echoscip-shell system . . echo. "### Start of Backup Rotation ###"
57 echoscip-shell system . . echo. "Using backup partition: $BACKUPPART"
58
59 echoscip-shell system . . echo. -n "Remounting backup partition read-write ... "
60 if ( mountscip-shell system . . mount. $BACKUPPART -o remount,rw &> /dev/nullscip-shell filesystem . . `/dev/null`. ) then
61 echoscip-shell system . . echo. "done."
62 else
63 echoscip-shell system . . echo. "failure!"
64 echoscip-shell system . . echo. "There were problems remounting $BACKUPPART in read-write mode!"
65 echoscip-shell system . . echo. "Rotation not made!"
66 echoscip-shell system . . echo. "### End of Backup Rotation ###"
67 exit 1
68 fi
69
70 echoscip-shell system . . echo. -n "Checking that no directory named \"$BACKUPDIR\" exists ... "
71 if [scip-shell system . . `[`. -d $BACKUPPART/$BACKUPDIR -a ! -L $BACKUPPART/$BACKUPDIR ]; then
72 echoscip-shell system . . echo. "failure!"
73 echoscip-shell system . . echo. "Directory \"$BACKUPDIR\" exists. Can't create link!"
74 echoscip-shell system . . echo. "Rotation not made!"
75
76 echoscip-shell system . . echo. -n "Remounting backup partition read-only ... "
77 if ( mountscip-shell system . . mount. $BACKUPPART -o remount,ro &> /dev/nullscip-shell filesystem . . `/dev/null`. ) then
78 echoscip-shell system . . echo. "done."
79 else
80 echoscip-shell system . . echo. "failure!"
81 echoscip-shell system . . echo. "There were problems remounting $BACKUPPART in read-only mode!"
82 echoscip-shell system . . echo. "### End of Backup Rotation ###"
83 exit 1
84 fi
85 echoscip-shell system . . echo. "### End of Backup Rotation ###"
86 exit 1
87 else
88 echoscip-shell system . . echo. "done."
89 fi
90
91 cd $BACKUPPART
92
93 echoscip-shell system . . echo. -n "Creating link: $BACKUPDIR --> $REALDIR ... "
94 if ( lnscip-shell system . . ln. -snf $REALDIR $BACKUPDIR &> /dev/nullscip-shell filesystem . . `/dev/null`. ) then
95 echoscip-shell system . . echo. "done."
96 else
97 echoscip-shell system . . echo. "failure!"
98 echoscip-shell system . . echo. "There were problems creating link!"
99 echoscip-shell system . . echo. "Rotation not made!"
100
101 echoscip-shell system . . echo. -n "Remounting backup partition read-only ... "
102 if ( mountscip-shell system . . mount. $BACKUPPART -o remount,ro &> /dev/nullscip-shell filesystem . . `/dev/null`. ) then
103 echoscip-shell system . . echo. "done."
104 else
105 echoscip-shell system . . echo. "failure!"
106 echoscip-shell system . . echo. "There were problems remounting $BACKUPPART in read-only mode!"
107 echoscip-shell system . . echo. "### End of Backup Rotation ###"
108 exit 1
109 fi
110 echoscip-shell system . . echo. "### End of Backup Rotation ###"
111 exit 1
112 fi
113
114 echoscip-shell system . . echo. -n "Remounting backup partition read-only ... "
115 if ( mountscip-shell system . . mount. $BACKUPPART -o remount,ro &> /dev/nullscip-shell filesystem . . `/dev/null`. ) then
116 echoscip-shell system . . echo. "done."
117 else
118 echoscip-shell system . . echo. "failure!"
119 echoscip-shell system . . echo. "There were problems remounting $BACKUPPART in read-only mode!"
120 echoscip-shell system . . echo. "### End of Backup Rotation ###"
121 exit 1
122 fi
123 echoscip-shell system . . echo. "### End of Backup Rotation ###"
124
125 ## end of script