<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><DIV>On Sep 11, 2007, at 5:44 AM, Mitch Gore wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><BR><BR><DIV><SPAN class="gmail_quote">On 9/11/07, <B class="gmail_sendername">Bruce Nordstrand</B> &lt;<A href="mailto:brucen@ksl.com.au">brucen@ksl.com.au</A>&gt; wrote:</SPAN><BLOCKQUOTE class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <BR><BR>Jon wrote:<BR>&gt;&gt; Oh, and I have to get myself a backup command to automatically put a<BR>&gt;&gt; backup somewhere else on the network. That or don't do Myth rebuilds<BR>&gt;&gt; when I haven't had enough sleep.... <BR>&gt;&gt;<BR><BR></BLOCKQUOTE><BR><BR>Here is mine.  Put in /etc/cron.daily/<BR> ----------------------------------------------------------------------------------------<BR> FN=mythtv_backup-$(date +%Y-%m-%d_%H:%M).sql<BR> DIR=/home/myth/.mythbackups<BR> <BR> mysqldump -u mythtv -pmythtv mythconverg -c &gt; $DIR/$FN<BR> <BR> # bzip our db backup so it takes alot less space<BR> bzip2 $DIR/$FN<BR> <BR> #delete any backup files that status haven't changed for over 3 days.<BR> rm $(find $DIR -ctime +3 -name "mythtv_backup*")<BR> ---------------------------------------------------------------------------------------<BR> <BR> This keeps 3 but can be modified easily.<BR> <BR></DIV></BLOCKQUOTE><BR></DIV><DIV>Not bad, I like how easy that is to change. Here's mine:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>---------</DIV><DIV>Crontab</DIV><DIV>---------</DIV><DIV>30 1 * * * /myth2/db/backup.pl</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>----------</DIV><DIV>/myth2/db/backup.pl</DIV><DIV>----------</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>#!/usr/bin/perl</DIV><DIV>$backuplog = "/var/log/mythtv/backup.log";</DIV><DIV>$filename = "/myth2/db/mythtv_backup_".`date | cut -c 1-3`;</DIV><DIV>$command = "mysqldump -u mythtv -pmythtv mythconverg -c &gt;".$filename;</DIV><DIV>$date = `date`;</DIV><DIV>`echo "Dumping database to $filename on $date" &gt;&gt; $backuplog`;</DIV><DIV>`$command`;</DIV><DIV>`echo "Optimizing database" &gt;&gt; $backuplog`;</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>$OPT_MYTHDB='/usr/share/doc/mythtv-0.20.2/contrib/optimize_mythdb.pl';</DIV><DIV>$LOG='/var/log/mythtv/optimize_mythdb.log';</DIV><DIV>$date = `date`;</DIV><DIV>`echo "Started $OPT_MYTHDB on $date" &gt;&gt; $LOG`;</DIV><DIV>`$OPT_MYTHDB &gt;&gt; $LOG`;</DIV><DIV>$date = `date`;</DIV><DIV>`echo "Finished $OPT_MYTHDB on $date" &gt;&gt; $LOG`; </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>----------</DIV><DIV>And again, this time with comments:</DIV><DIV>----------</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>#!/usr/bin/perl</DIV><DIV>$backuplog = "/var/log/mythtv/backup.log";  &lt;-- I keep a log of every time it runs</DIV><DIV>$filename = "/myth2/db/mythtv_backup_".`date | cut -c 1-3`; &lt;---this names the file with the day of the week</DIV><DIV>$command = "mysqldump -u mythtv -pmythtv mythconverg -c &gt;".$filename; &lt;---actual command to backup the database</DIV><DIV>$date = `date`; &lt;--- date for the next line... I probably could do this differently, but this works</DIV><DIV>`echo "Dumping database to $filename on $date" &gt;&gt; $backuplog`; &lt;--- this is appending to my log the date and an entry that the command was run</DIV><DIV>`$command`; &lt;---backup the db</DIV><DIV>`echo "Optimizing database" &gt;&gt; $backuplog`; &lt;-- telling the log I'm going to optimize</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The following optimizes the database:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>$OPT_MYTHDB='/usr/share/doc/mythtv-0.20.2/contrib/optimize_mythdb.pl';</DIV><DIV>$LOG='/var/log/mythtv/optimize_mythdb.log';</DIV><DIV>$date = `date`;</DIV><DIV>`echo "Started $OPT_MYTHDB on $date" &gt;&gt; $LOG`;</DIV><DIV>`$OPT_MYTHDB &gt;&gt; $LOG`;</DIV><DIV>$date = `date`;</DIV><DIV>`echo "Finished $OPT_MYTHDB on $date" &gt;&gt; $LOG`;</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>so there you have it.... it could definately be made more simple, but that's how I do it.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>~Jon</DIV></BODY></HTML>