1 |
#!/bin/bash |
2 |
#------------------------------------------------------------------------------------------------- |
3 |
#$Header$ |
4 |
#------------------------------------------------------------------------------------------------- |
5 |
#This file is part of "Server Scripts, Automatic Maintenance, Cron", a set of scripts for |
6 |
#performing automatic periodic maintenance on a Linux server. |
7 |
#------------------------------------------------------------------------------------------------- |
8 |
#This source code and any program in which it is compiled/used is provided under the MIT License, |
9 |
#reproduced below. |
10 |
#------------------------------------------------------------------------------------------------- |
11 |
#Permission is hereby granted, free of charge, to any person obtaining a copy of |
12 |
#this software and associated documentation files(the "Software"), to deal in the |
13 |
#Software without restriction, including without limitation the rights to use, |
14 |
#copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the |
15 |
#Software, and to permit persons to whom the Software is furnished to do so, |
16 |
#subject to the following conditions : |
17 |
# |
18 |
#The above copyright notice and this permission notice shall be included in all |
19 |
#copies or substantial portions of the Software. |
20 |
# |
21 |
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
22 |
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
23 |
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE |
24 |
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
25 |
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
26 |
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
27 |
#SOFTWARE. |
28 |
#------------------------------------------------------------------------------------------------- |
29 |
#Full monthly backup Dave Ashley's server content. |
30 |
# |
31 |
echo "Performing full backup of all Dave Ashley's server content." |
32 |
# |
33 |
#Change to a safe working directory in case something goes wrong, |
34 |
#especially a failed cd followed by a mass delete. |
35 |
cd /root/cronjob_sandbox |
36 |
# |
37 |
#Remove the existing old backup. This is because don't have the storage and don't want to purchase |
38 |
#a new SSD, so delete the old before making the new. |
39 |
rm -fR /hl/baks/ashley_david_personal_01/full_monthly/* |
40 |
# |
41 |
#Make the main directory for all backup content. |
42 |
mkdir /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14} |
43 |
# |
44 |
#Make the sub-directory for the full backup. |
45 |
mkdir /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/full |
46 |
# |
47 |
#Make MD5 message digests of everything we intend to tar up in the main backup. |
48 |
find -L /hb/ashley_david_personal_01/full_monthly -type f -exec md5sum '{}' \; &>/hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/full/${1}${5}${6}_${10}${13}${14}.files.md5sum.txt |
49 |
# |
50 |
#Make SHA512 message digests of everything we intend to tar up in the main backup. |
51 |
find -L /hb/ashley_david_personal_01/full_monthly -type f -exec sha512sum '{}' \; &>/hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/full/${1}${5}${6}_${10}${13}${14}.files.sha512sum.txt |
52 |
# |
53 |
#Tar up everything in the main backup except for the backup symlinks themselves. |
54 |
tar -c -v -z -h -f /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/full/${1}${5}${6}_${10}${13}${14}.files.tar.gz /hb/ashley_david_personal_01/full_monthly &>/hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/full/${1}${5}${6}_${10}${13}${14}.files.log.txt |
55 |
# |
56 |
#Tar up the main backup symlinks. |
57 |
tar -c -v -z -f /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/full/${1}${5}${6}_${10}${13}${14}.symlinks.tar.gz /hb/ashley_david_personal_01/full_monthly &>/hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/full/${1}${5}${6}_${10}${13}${14}.symlinks.log.txt |
58 |
# |
59 |
#Emit the main backup file MD5s to stdout so they go in the larger log. |
60 |
echo "===== FILE MD5 MESSAGE DIGESTS =====" |
61 |
cat /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/full/${1}${5}${6}_${10}${13}${14}.files.md5sum.txt |
62 |
# |
63 |
#Emit the main backup file SHA512s to stdout so they go in the larger log. |
64 |
echo "===== FILE SHA512 MESSAGE DIGESTS =====" |
65 |
cat /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/full/${1}${5}${6}_${10}${13}${14}.files.sha512sum.txt |
66 |
# |
67 |
#Emit the main backup log files to stdout so they go in the larger log. |
68 |
echo "===== FILES =====" |
69 |
cat /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/full/${1}${5}${6}_${10}${13}${14}.files.log.txt |
70 |
# |
71 |
#Emit the main backup symlink backup log files to stdout so they go in the larger log. |
72 |
echo "===== SYMLINKS =====" |
73 |
cat /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/full/${1}${5}${6}_${10}${13}${14}.symlinks.log.txt |
74 |
# |
75 |
#We want to be really careful with this next section because of |
76 |
#the recursive rm. Want to be sure the directory exists. |
77 |
if [ -d /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/full ] ; then |
78 |
cd /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/full |
79 |
split -b 1000m ${1}${5}${6}_${10}${13}${14}.files.tar.gz |
80 |
XFILES=`ls -1 x*` |
81 |
for curfile in $XFILES |
82 |
do |
83 |
mv ${curfile} ${curfile}.bin |
84 |
done |
85 |
md5sum ${1}${5}${6}_${10}${13}${14}.* x* >md5sums.txt |
86 |
sha512sum ${1}${5}${6}_${10}${13}${14}.* x* >sha512sums.txt |
87 |
rm ${1}${5}${6}_${10}${13}${14}.files.tar.gz |
88 |
# |
89 |
#Emit the backup file MD5s to stdout so they go in the larger log. |
90 |
echo "===== BACKUP FILE MD5 MESSAGE DIGESTS =====" |
91 |
cat md5sums.txt |
92 |
# |
93 |
#Emit the backup file SHA512s to stdout so they go in the larger log. |
94 |
echo "===== BACKUP FILE SHA512 MESSAGE DIGESTS =====" |
95 |
cat sha512sums.txt |
96 |
# |
97 |
#Commented out because now deleting old before making new. There will |
98 |
#be only one directory. |
99 |
#cd .. |
100 |
#rm -fR `ls -1t | sed -e '2,$!d'` |
101 |
fi |
102 |
# |
103 |
#Change to a safe working directory in case something goes wrong, |
104 |
#especially a failed cd followed by a mass delete. |
105 |
cd /root/cronjob_sandbox |
106 |
# |
107 |
#Make the sub-directory for svn repository backups. |
108 |
mkdir /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/svn |
109 |
# |
110 |
#Make the sub-directory for svn repository backups of svn repository "dtapublic". |
111 |
mkdir /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/svn/dtapublic |
112 |
# |
113 |
#Make MD5 message digests of everything in the repository "dtapublic". |
114 |
find -L /hl/svnroots/dtapublic -type f -exec md5sum '{}' \; &>/hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/svn/dtapublic/${1}${5}${6}_${10}${13}${14}.files.md5sum.txt |
115 |
# |
116 |
#Make SHA512 message digests of everything in the repository "dtapublic". |
117 |
find -L /hl/svnroots/dtapublic -type f -exec sha512sum '{}' \; &>/hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/svn/dtapublic/${1}${5}${6}_${10}${13}${14}.files.sha512sum.txt |
118 |
# |
119 |
#Tar up the svn repository, "dtapublic". |
120 |
tar -c -v -z -h -f /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/svn/dtapublic/${1}${5}${6}_${10}${13}${14}.files.tar.gz /hl/svnroots/dtapublic &>/hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/svn/dtapublic/${1}${5}${6}_${10}${13}${14}.files.log.txt |
121 |
# |
122 |
#Emit the svn repository "dtapublic" backup file MD5s to stdout so they go in the larger log. |
123 |
echo "===== FILE MD5 MESSAGE DIGESTS =====" |
124 |
cat /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/svn/dtapublic/${1}${5}${6}_${10}${13}${14}.files.md5sum.txt |
125 |
# |
126 |
#Emit the svn repository "dtapublic" backup file SHA512s to stdout so they go in the larger log. |
127 |
echo "===== FILE SHA512 MESSAGE DIGESTS =====" |
128 |
cat /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/svn/dtapublic/${1}${5}${6}_${10}${13}${14}.files.sha512sum.txt |
129 |
# |
130 |
#Emit the svn repository "dtapublic" backup log files to stdout so they go in the larger log. |
131 |
echo "===== FILES =====" |
132 |
cat /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/svn/dtapublic/${1}${5}${6}_${10}${13}${14}.files.log.txt |
133 |
# |
134 |
#We want to be really careful with this next section because of |
135 |
#the recursive rm. Want to be sure the directory exists. |
136 |
if [ -d /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/svn/dtapublic ] ; then |
137 |
cd /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/svn/dtapublic |
138 |
split -b 1000m ${1}${5}${6}_${10}${13}${14}.files.tar.gz |
139 |
|
140 |
XFILES=`ls -1 x*` |
141 |
for curfile in $XFILES |
142 |
do |
143 |
mv ${curfile} ${curfile}.bin |
144 |
done |
145 |
md5sum ${1}${5}${6}_${10}${13}${14}.* x* >md5sums.txt |
146 |
sha512sum ${1}${5}${6}_${10}${13}${14}.* x* >sha512sums.txt |
147 |
rm ${1}${5}${6}_${10}${13}${14}.files.tar.gz |
148 |
# |
149 |
#Emit the backup file MD5s to stdout so they go in the larger log. |
150 |
echo "===== BACKUP FILE MD5 MESSAGE DIGESTS =====" |
151 |
cat md5sums.txt |
152 |
# |
153 |
#Emit the backup file SHA512s to stdout so they go in the larger log. |
154 |
echo "===== BACKUP FILE SHA512 MESSAGE DIGESTS =====" |
155 |
cat sha512sums.txt |
156 |
# |
157 |
#Commented out because now deleting old before making new. There will |
158 |
#be only one directory. |
159 |
#cd .. |
160 |
#rm -fR `ls -1t | sed -e '2,$!d'` |
161 |
fi |
162 |
# |
163 |
#Change to a safe working directory in case something goes wrong, |
164 |
#especially a failed cd followed by a mass delete. |
165 |
cd /root/cronjob_sandbox |
166 |
# |
167 |
#End of script. |