summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/lh_system_backup_job
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2013-12-03 22:17:25 (GMT)
committerJames Meyer <james.meyer@operamail.com>2013-12-03 22:17:25 (GMT)
commitd5370e5d6fe083e14866c5b5d1728fea4f9879bc (patch)
tree23a53195111dc6a098d17308486440899ecf0341 /abs/core/LinHES-system/lh_system_backup_job
parentba4ef74d5cd87084bd5c328fbbc254208e5e84a6 (diff)
downloadlinhes_pkgbuild-d5370e5d6fe083e14866c5b5d1728fea4f9879bc.zip
linhes_pkgbuild-d5370e5d6fe083e14866c5b5d1728fea4f9879bc.tar.gz
linhes_pkgbuild-d5370e5d6fe083e14866c5b5d1728fea4f9879bc.tar.bz2
LinHES-system: systembackup
lh_system_backup_job. Fix sed problem when adjusting the meny xml . Changed > to -gt to force bash int test instead of string add timestamps to myth_mtc.py and general cleanup
Diffstat (limited to 'abs/core/LinHES-system/lh_system_backup_job')
-rw-r--r--abs/core/LinHES-system/lh_system_backup_job38
1 files changed, 24 insertions, 14 deletions
diff --git a/abs/core/LinHES-system/lh_system_backup_job b/abs/core/LinHES-system/lh_system_backup_job
index 9b878bd..7d05be5 100644
--- a/abs/core/LinHES-system/lh_system_backup_job
+++ b/abs/core/LinHES-system/lh_system_backup_job
@@ -43,15 +43,19 @@ function backup(){
pacman -Q mysql 2>/dev/null
if [ $? = 0 ]
then
+ echo " mythconverg (mythtv database)"
mysqldump -x mythconverg > $BACKUPDIR/$DATE/mythconverg
backup_status_check $?
- mysqldump -x ncid > $BACKUPDIR/$DATE/ncid
+ echo " ncid (caller id)"
+ mysqldump -x ncid > $BACKUPDIR/$DATE/ncid 2>/dev/null
#this is all the users
+ echo " users"
mysqldump -x mysql > $BACKUPDIR/$DATE/mysql_table
#this is everything
+ echo " All databases in one file"
mysqldump -x --all-databases > $BACKUPDIR/$DATE/all_databases
backup_status_check $?
@@ -117,6 +121,7 @@ function backup(){
}
function update_backup_status(){
+ echo
# Add Last backup status to menu item
#if description not in the backup xml file, add it
if [ $rc=0 ]
@@ -125,7 +130,8 @@ function update_backup_status(){
else
COMPLETE_MSG="Last backup FAILED `date '+%D %-I:%M %p'`"
fi
-
+ echo "Updating menu with:"
+ echo " $COMPLETE_MSG"
xmlfile="/usr/share/mythtv/themes/defaultmenu/mythbackup.xml"
grep -q "<description>" $xmlfile >/dev/null
@@ -133,16 +139,18 @@ function update_backup_status(){
if [ $desc_check = 0 ]
then
- sed -i "0,/\<description\>.*\<description\>/s//\<description\>$COMPLETE_MSG\<\/description/" $xmlfile
+ sed -i "0,/<description\>.*\<description\>/s||\<description\>$COMPLETE_MSG<\/description|" $xmlfile
+ #sed -i "0,/\<description\>.*\<description\>/s//\<description\>$COMPLETE_MSG\<\/description/" $xmlfile
else
sed -i " /NONE/ i\ \<description\>$COMPLETE_MSG\<\/description\>" $xmlfile
fi
}
function remove_old_backups(){
+
#remove old backups
NumBackups=`ls $BACKUPDIR/backup*.tgz|wc -l`
- if [[ $NumBackups > $KeepBackups ]]; then
+ if [[ $NumBackups -gt $KeepBackups ]]; then
numdel=$(($NumBackups-$KeepBackups))
rm -f `ls $BACKUPDIR/backup*.tgz -tr1|head -$numdel`
fi
@@ -150,6 +158,8 @@ function remove_old_backups(){
function remote_backup(){
+ echo
+ echo "Remote backup"
#Remote copy
if [ x$RemoteBackup = x1 ]
then
@@ -157,7 +167,7 @@ function remote_backup(){
if [ x$localRemoteCheck = xdir ]
then
localRemotedir=`echo $RemoteBackupDir | cut -d: -f2`
- echo "copying $BACKUPDIR/backup.$DATE.tgz to $localRemotedir "
+ echo " copying $BACKUPDIR/backup.$DATE.tgz to $localRemotedir "
cp $BACKUPDIR/backup.$DATE.tgz $localRemotedir
else
/usr/bin/func ${RemoteBackupDir} ping| grep -q "FAILED"
@@ -166,15 +176,15 @@ function remote_backup(){
then
#this is here to mark failed copy of the backup.
#There is a cron.hourly job that will attempt to retransfer the file
- echo "Remote backup failed to ${RemoteBackupDir}"
+ echo " Remote backup failed to ${RemoteBackupDir}"
echo backup.$DATE.tgz >> $BACKUPDIR/remote_backup_failed.txt
else
- echo "copying $BACKUPDIR/backup.$DATE.tgz to ${RemoteBackupDir}:$BACKUPDIR/MBE_$DATE.tgz"
+ echo " copying $BACKUPDIR/backup.$DATE.tgz to ${RemoteBackupDir}:$BACKUPDIR/MBE_$DATE.tgz"
/usr/bin/func ${RemoteBackupDir} copyfile -f $BACKUPDIR/backup.$DATE.tgz --remotepath $BACKUPDIR/MBE_$DATE.tgz
fi
fi
else #do local copy to SECBACKUPLINK
- echo "Remote backup is not enabled, copying backup to $SECBACKUPLINK if it exists"
+ echo " Remote backup is not enabled, copying backup to $SECBACKUPLINK if it exists"
SECBACKUPDISK=`readlink $SECBACKUPLINK`
SECBACKUP=$SECBACKUPDISK/backup
@@ -182,16 +192,16 @@ function remote_backup(){
if [ `mountpoint -q -d $SECBACKUPDISK` ]; then
if [ ! -d "$SECBACKUP" ]; then
mkdir -p -m 775 $SECBACKUP
- echo "Created $SECBACKUP"
+ echo " Created $SECBACKUP"
chown mythtv:users $SECBACKUP
fi
- echo "Copying systems_backups"
+ echo " Copying system backups to $SECBACKUP"
rsync -au --delete $BACKUPDIR $SECBACKUP
else
- echo "$SECBACKUPDISK isn't mounted."
+ echo "* $SECBACKUPDISK isn't mounted."
fi
else
- echo "Link $SECBACKUPLINK doesn't exist."
+ echo "* Link $SECBACKUPLINK doesn't exist."
fi
fi
}
@@ -205,10 +215,10 @@ function remote_transfer(){
then
#this is here to mark a failed copy of the backup.
#There is a cron.hourly job that will attempt to retransfer the file
- echo "Remote backup failed to ${RemoteBackupDir}"
+ echo " Remote backup failed to ${RemoteBackupDir}"
echo $transfer_file >> $BACKUPDIR/remote_backup_failed.txt
else
- echo "copying $BACKUPDIR/$transfer_file to ${RemoteBackupDir}:$BACKUPDIR/MBE_$transfer_file"
+ echo " copying $BACKUPDIR/$transfer_file to ${RemoteBackupDir}:$BACKUPDIR/MBE_$transfer_file"
/usr/bin/func ${RemoteBackupDir} copyfile -f $BACKUPDIR/$transfer_file --remotepath $BACKUPDIR/MBE_$transfer_file
fi
}