Subversion Repositories SmartDukaan

Rev

Rev 2474 | Rev 4385 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1390 chandransh 1
#!/bin/bash
2
 
3
ECHO="`which echo`"
4
DATEC="`which date`"
5
FIND="`which find`"
6
CP="`which cp`"
7
RM="`which rm`"
8
 
9
DATE=`${DATEC} +%Y-%b-%d_%Hh%Mm`
2474 rajveer 10
BACKUP_DIR="/data/CMS-daily-backup/"
1391 chandransh 11
LOGFILE=${BACKUP_DIR}/${DATE}.log		# Log file Name
12
LOGERR=${BACKUP_DIR}/ERRORS-${DATE}.log		# Error Log file Name
1390 chandransh 13
 
14
# IO redirection for logging.
15
touch ${LOGFILE}
16
exec 6>&1           # Link file descriptor #6 with stdout.
17
                    # Saves stdout.
18
exec > ${LOGFILE}     # stdout replaced with file ${LOGFILE}.
19
touch ${LOGERR}
20
exec 7>&2           # Link file descriptor #7 with stderr.
21
                    # Saves stderr.
22
exec 2> ${LOGERR}     # stderr replaced with file ${LOGERR}.
23
 
24
${ECHO} Content DB Backup Start Time `${DATEC}`
25
${ECHO} ======================================================================
26
 
27
mkdir $BACKUP_DIR/${DATE}
28
${CP} -r /var/lib/tomcat6/webapps/db ${BACKUP_DIR}/${DATE}
29
 
30
${ECHO} Content DB Backup End Time `${DATEC}`
31
${ECHO} ======================================================================
32
 
3816 chandransh 33
${ECHO} Cleaning up backups older than 3 days
1390 chandransh 34
${ECHO} ======================================================================
3816 chandransh 35
find $BACKUP_DIR -mtime +3 -exec ${RM} -rv {} \;
1390 chandransh 36
 
37
#Clean up IO redirection
38
exec 1>&6 6>&-      # Restore stdout and close file descriptor #6.
39
exec 2>&7 7>&-      # Restore stdout and close file descriptor #7.
40
 
41
if [ -s "${LOGERR}" ]
42
	then
43
		exit 1
44
	else
45
		exit 0
46
fi