]>
Commit | Line | Data |
---|---|---|
1733496b SP |
1 | #!/bin/bash |
2 | # | |
3 | # This script will redirect the backup directory to implement desired backup | |
4 | # schedules. | |
5 | # | |
6 | # Currently we will use just a seven day format were we just move a link | |
7 | # that represents the backup directory, to point to the day of the week. | |
8 | # | |
9 | ||
10 | # | |
11 | # Configuration Parameters | |
12 | # | |
13 | ||
14 | if [ "$1" = "monthly" ]; then | |
15 | REALDIR="monthly" | |
16 | else | |
17 | REALDIR=`date +%A` | |
18 | fi | |
19 | ||
20 | BACKUPPART="/backup" | |
21 | BACKUPDIR="current" | |
22 | ||
23 | echo "### Start of Backup Rotation ###" | |
24 | echo "Using backup partition: $BACKUPPART" | |
25 | ||
26 | echo -n "Remounting backup partition read-write ... " | |
27 | if ( mount $BACKUPPART -o remount,rw &> /dev/null ) then | |
28 | echo "done." | |
29 | else | |
30 | echo "failure!" | |
31 | echo " There were problems remounting $BACKUPPART in read-write mode!" | |
32 | echo "Rotation not made!" | |
33 | echo "### End of Backup Rotation ###" | |
34 | exit 1 | |
35 | fi | |
36 | ||
37 | echo -n "Checking that no directory named \"$BACKUPDIR\" exists ... " | |
38 | if [ -d $BACKUPPART/$BACKUPDIR -a ! -L $BACKUPPART/$BACKUPDIR ]; then | |
39 | echo "failure!" | |
40 | echo " Directory \"$BACKUPDIR\" exists. Can't create link!" | |
41 | echo "Rotation not made!" | |
42 | ||
43 | echo -n "Remounting backup partition read-only ... " | |
44 | if ( mount $BACKUPPART -o remount,ro &> /dev/null ) then | |
45 | echo "done." | |
46 | else | |
47 | echo "failure!" | |
48 | echo " There were problems remounting $BACKUPPART in read-only mode!" | |
49 | echo "### End of Backup Rotation ###" | |
50 | exit 1 | |
51 | fi | |
52 | echo "### End of Backup Rotation ###" | |
53 | exit 1 | |
54 | else | |
55 | echo "done." | |
56 | fi | |
57 | ||
58 | cd $BACKUPPART | |
59 | ||
60 | echo -n "Creating link: $BACKUPDIR --> $REALDIR ... " | |
61 | if ( ln -snf $REALDIR $BACKUPDIR &> /dev/null ) then | |
62 | echo "done." | |
63 | else | |
64 | echo "failure!" | |
65 | echo " There were problems creating link!" | |
66 | echo "Rotation not made!" | |
67 | ||
68 | echo -n "Remounting backup partition read-only ... " | |
69 | if ( mount $BACKUPPART -o remount,ro &> /dev/null ) then | |
70 | echo "done." | |
71 | else | |
72 | echo "failure!" | |
73 | echo " There were problems remounting $BACKUPPART in read-only mode!" | |
74 | echo "### End of Backup Rotation ###" | |
75 | exit 1 | |
76 | fi | |
77 | echo "### End of Backup Rotation ###" | |
78 | exit 1 | |
79 | fi | |
80 | ||
81 | echo -n "Remounting backup partition read-only ... " | |
82 | if ( mount $BACKUPPART -o remount,ro &> /dev/null ) then | |
83 | echo "done." | |
84 | else | |
85 | echo "failure!" | |
86 | echo " There were problems remounting $BACKUPPART in read-only mode!" | |
87 | echo "### End of Backup Rotation ###" | |
88 | exit 1 | |
89 | fi | |
90 | echo "### End of Backup Rotation ###" |