LinHES Forums http://forums.linhes.org/ |
|
mythbackup via cron http://forums.linhes.org/viewtopic.php?f=3&t=18000 |
Page 1 of 1 |
Author: | bobmyth [ Wed Mar 05, 2008 9:09 pm ] |
Post subject: | mythbackup via cron |
I am not the best about backing-up my myth box and it could have saved me a few times. I've created script that can be called from a cron job to automatically backup my system. The script attempts to make sure your backend is not recording before performing the backup. Code: #/bin/sh file=/tmp/status.html wget -q -O $file http://localhost:6544 # Make sure backend is not already recording grep -q 'is recording' $file if test $? -eq 0 ; then # Some encoder is recording exit 0 fi mythbackup if $? -ne 0 ; then echo "Warning: mythbackup failed!" fi rm -f $file I store this as run-mythbackup and have it execute from /etc/crontab once a week on Sunday: Code: 15 4 * * 0 root /usr/local/bin/run-mythbackup
|
Author: | mjl [ Wed Mar 05, 2008 11:41 pm ] |
Post subject: | |
Hi, I also modified the menu halt button so my box does a backup before shutdown. That way if I forget to do a backup before going for an upgrade I don't hose myself As always, watch for line wrapping. halt-control.sh Code: #<code>
#!/bin/bash # Shutdown mesage lsmod |grep "ivtvfb "|cut -b1-6 >/tmp/tv if [ $(cat /tmp/tv) = "ivtvfb" ]; then fontsize="26" fontcolor="lightyellow" else fontsize="34" fontcolor="yellow" fi killall xterm sudo killall mythfrontend& echo "Starting Backup, followed with Shutdown" > /tmp/ver echo "This may take a few minutes...." >> /tmp/ver export DISPLAY=:0 export FONT="-adobe-helvetica-bold-*-*-*-$fontsize-*-*-*-*-*-*-*" cat /tmp/ver | osd_cat --delay=180 --font=$FONT --color=$fontcolor --shadow=2 --pos=middle --align=centre& festival --tts /tmp/ver >/dev/null (play /usr/share/sounds/beg.wav) > /dev/null sleep 1 sudo /usr/local/bin/mythbackup killall osd_cat (play /usr/share/sounds/end.wav)& > /dev/null sleep 3 #(play /myth/saytime/gas.wav)& > /dev/null sudo halt #<end code> Mike |
Author: | tjc [ Thu Mar 06, 2008 6:45 pm ] |
Post subject: | |
Also see the discussion in this thread for a more robust script. http://knoppmyth.net/phpBB2/viewtopic.php?t=17988 |
Author: | bobmyth [ Thu Mar 06, 2008 9:17 pm ] |
Post subject: | |
Thanks for the suggestion. This is much better: Code: #/bin/sh
# Make sure backend is not busy mythshutdown -s if test $? -ne 0 ; then # 1 = transcoding, 2 = comm flag, 4 = grabbing data, 16 = locked exit 0 fi mythbackup if $? -ne 0 ; then echo "Warning: mythbackup failed!" fi |
Author: | tjc [ Thu Mar 06, 2008 9:36 pm ] |
Post subject: | |
Well, the intent was actually to have you try the idle.sh script posted in that thread which is substantially smarter about current and upcoming system activity... |
Author: | tjc [ Sat Mar 08, 2008 3:55 pm ] |
Post subject: | |
I've published a link to the full blown idle.sh script in the thread mjl refers to above. - Download it from there and put it in /usr/local/bin - Make sure it's owned by root and has execute permissions: Code: chown root:root /usr/local/bin/idle.sh chmod u=rwx,go=rx /usr/local/bin/idle.sh - Change your cron command to be something like: Code: /usr/local/bin/idle.sh -s && /usr/local/bin/mythbackup >/var/log/backup.log 2>&1 Another possibility is to do something like this Code: (/usr/local/bin/idle.sh && /usr/local/bin/mythbackup) >/var/log/backup.log 2>&1
Which will include the verbose output from idle.sh in the log file. Note that both of these should be run as root to allow writing the logs in /var/log - If you want to get really fancy configure the logfile rolling to keep a recent history of the logs. |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |