LinHES Forums
http://forums.linhes.org/

Regular Maintenance
http://forums.linhes.org/viewtopic.php?f=21&t=24043
Page 1 of 1

Author:  nicom [ Sun Aug 24, 2014 9:02 pm ]
Post subject:  Regular Maintenance

Since I first started using Knoppmyth/LinHES I have always shutdown and used ACPI wake. Back when I was running R5.5 I developed a script (discussed here) to perform regular maintenance when the machine shutdown via mythwelcome. On successive shutdowns the script would:
1. Optimize the db
2. Perform a backup including a secondary backup to an alternate drive
3. Defragment the xfs drives
4. Maintain a copy of videos, music and gallery

I maintained and updated the script through R6 and R7 but now that I have upgraded to R8 I find it is redundant. Optimize and backup up (including secondary) are both done daily as part of myth_mtc and defrag is done as a weekly cron job. I think I will probably change task 4 to a cron job as well and do away with the shutdown script altogether.

From what I have read LinHES uses cron, not anacron or cronie and that weekly jobs are timed to execute at midnight Sunday morning. Therefore if my machine is shutdown at that time it would not run. In order to test it I added a trace to the “checkXFSdefrag.sh” script (I think that’s the name) which also logged the time and date into /var/log/xfsdefrag.log. Yesterday I looked and found that cron had executed the script at about 17:41 Saturday which roughly corresponded to when I turned the machine on manually. This is not what I was expecting but am happy it works.

Does cron have some cleverness that I don’t understand?

Author:  brfransen [ Mon Aug 25, 2014 7:40 am ]
Post subject:  Re: Regular Maintenance

nicom wrote:
Does cron have some cleverness that I don’t understand?
LinHES uses dcron which has many of the benefits of anacron, including running missed hourly, daily, monthly, etc jobs.

Author:  nicom [ Wed Aug 27, 2014 8:16 pm ]
Post subject:  Re: Regular Maintenance

Thanks Britney, that explains it.

Author:  nicom [ Fri Sep 12, 2014 5:58 pm ]
Post subject:  Re: Regular Maintenance

As I said in my first post I was going to convert my media backup to a cron job. If anyone is interested this is script I prepared which I keep in the mythtv home directory for upgrade reasons then copy to /etc/cron.weekly
Code:
#!/bin/bash
#
# mediabackup.sh
#
# This script copies videos, music and gallery to the secondary disk
# It is run as a weekly cron job
#
# Copy this file to /etc/cron.weekly maintaining root:root ownership
#     sudo cp /home/mythtv/mediabackup/mediabackup.sh /etc/cron.weekly
#
BACKUPDIR=/data/storage/disk1/backup/user_backups/media-backup

   echo `date` > /home/mythtv/mediabackup/mediabackup.log
   echo `rsync -vrt --delete /myth/video $BACKUPDIR` >> /home/mythtv/mediabackup/mediabackup.log
   echo `rsync -vrt --delete /myth/music $BACKUPDIR` >> /home/mythtv/mediabackup/mediabackup.log
   echo `rsync -vrt --delete /myth/gallery $BACKUPDIR` >> /home/mythtv/mediabackup/mediabackup.log
   echo `date` : Completed media backup >> /home/mythtv/mediabackup/mediabackup.log

Alice, I think you may have posted in the wrong thread.

Author:  nicom [ Sat Sep 13, 2014 4:45 pm ]
Post subject:  Re: Regular Maintenance

Looking at the logs for the regular defraging script (/var/log/xfs_defrag.log) I noticed that /dev/sda7 was tested twice
Code:
/dev/sda7   0 is not above fragmentation threshold of 15.
/dev/sda7   0 is not above fragmentation threshold of 15.
/dev/sdb3   3 is not above fragmentation threshold of 15.
I worked out the reason for this is that the script uses df to detect the xfs partitions and df outputs all mounting points so /dev/sda7 gets a mention as /data/storage/disk0 as well as /data/storage/full-name-of-disk.
Would it not be neater to use blkid to identify the xfs partitions? As a test I have modified the /usr/LH/bin/checkXFSfrag.sh as follows
Code:
array=`blkid|grep xfs|cut -f 1 --delim=":"`     #added line - change to avoid multiple listing of /dev/sda7 14sep14
#array=`df -T|grep xfs|cut -f 1 --delim=" "`     # Array of all XFS file systems. (original line)
Running this from the command line works well. Note that the delimiter had to be changed from a space to a colon to suit the output of blkid. I will let cron run it for a while and see how it goes.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/