/[dtapublic]/projs/trunk/projs/20161029_server_scripts_automaint_cron/backup_ashley_david_pers_full
ViewVC logotype

Contents of /projs/trunk/projs/20161029_server_scripts_automaint_cron/backup_ashley_david_pers_full

Parent Directory Parent Directory | Revision Log Revision Log


Revision 76 - (show annotations) (download)
Sat Nov 5 23:16:39 2016 UTC (7 years, 10 months ago) by dashley
File size: 5725 byte(s)
Modified to save SSD space by deleting old full backup before creating new.
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 directory.
42 mkdir /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}
43 #
44 #Make MD5 message digests of everything we intend to tar up.
45 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}/${1}${5}${6}_${10}${13}${14}.files.md5sum.txt
46 #
47 #Make SHA512 message digests of everything we intend to tar up.
48 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}/${1}${5}${6}_${10}${13}${14}.files.sha512sum.txt
49 #
50 #Tar up everything except for the backup symlinks themselves.
51 tar -c -v -z -h -f /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/${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}/${1}${5}${6}_${10}${13}${14}.files.log.txt
52 #
53 #Tar up the symlinks.
54 tar -c -v -z -f /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/${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}/${1}${5}${6}_${10}${13}${14}.symlinks.log.txt
55 #
56 #Emit the file MD5s to stdout so they go in the larger log.
57 echo "===== FILE MD5 MESSAGE DIGESTS ====="
58 cat /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/${1}${5}${6}_${10}${13}${14}.files.md5sum.txt
59 #
60 #Emit the file SHA512s to stdout so they go in the larger log.
61 echo "===== FILE SHA512 MESSAGE DIGESTS ====="
62 cat /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/${1}${5}${6}_${10}${13}${14}.files.sha512sum.txt
63 #
64 #Emit the log files to stdout so they go in the larger log.
65 echo "===== FILES ====="
66 cat /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/${1}${5}${6}_${10}${13}${14}.files.log.txt
67 #
68 echo "===== SYMLINKS ====="
69 cat /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}/${1}${5}${6}_${10}${13}${14}.symlinks.log.txt
70 #
71 #We want to be really careful with this next section because of
72 #the recursive rm. Want to be sure the directory exists.
73 if [ -d /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14} ] ; then
74 cd /hl/baks/ashley_david_personal_01/full_monthly/${1}${5}${6}_${10}${13}${14}
75 split -b 1000m ${1}${5}${6}_${10}${13}${14}.files.tar.gz
76 XFILES=`ls -1 x*`
77 for curfile in $XFILES
78 do
79 mv ${curfile} ${curfile}.bin
80 done
81 md5sum ${1}${5}${6}_${10}${13}${14}.* x* >md5sums.txt
82 sha512sum ${1}${5}${6}_${10}${13}${14}.* x* >sha512sums.txt
83 rm ${1}${5}${6}_${10}${13}${14}.files.tar.gz
84 #
85 #Emit the backup file MD5s to stdout so they go in the larger log.
86 echo "===== BACKUP FILE MD5 MESSAGE DIGESTS ====="
87 cat md5sums.txt
88 #
89 #Emit the backup file SHA512s to stdout so they go in the larger log.
90 echo "===== BACKUP FILE SHA512 MESSAGE DIGESTS ====="
91 cat sha512sums.txt
92 #
93 #Commented out because now deleting old before making new. There will
94 #be only one directory.
95 #cd ..
96 #rm -fR `ls -1t | sed -e '2,$!d'`
97 fi
98 #
99 #Change to a safe working directory in case something goes wrong,
100 #especially a failed cd followed by a mass delete.
101 cd /root/cronjob_sandbox
102 #
103 #End of script.

Properties

Name Value
svn:eol-style native
svn:executable *
svn:keywords Header

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25