From MythTV Official Wiki
Revision as of 21:54, 27 November 2012 by PhilB (talk | contribs) (Created page with "{{Wrongtitle|}} {{Script info |author=Phil Brady |short=Daily database backup at end of day |long=Daily database backup at end of day |category=Maintenance |file=...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Important.png Note: The correct title of this article is It appears incorrectly here due to technical restrictions.

Author Phil Brady
Description Daily database backup at end of day


Readers may be interested in an approach to automating database backups of a mythtv system. This mechanism can be used with dedicated Mythbuntu frontend/backend with mythwelcome and ACPI wakeup.

It was thought that database backups should be taken:

  • daily
  • on days when recording had been made
  • at a time when the system was otherwise idle
  • preferably at the end of the day
  • if a recording should straddle midnight, the backup should be after that had finished, so 'end of day' needs defining as 4am.

This is achieved by a bash script which is placed in /usr/bin/ and which calls as appropriate. It is called itself from the recording start system event and from within

The script can be placed in /usr/bin/


Execute permissions need to be set; two log files need creating and a directory creating for the backups:

#make script executable
sudo chmod 755 /usr/bin/
#create log files
sudo touch /var/log/mythtv/autobackup.log
sudo touch /var/log/mythtv/autobackup.log.1
sudo chmod 666 /var/log/mythtv/autobackup.*

#create backup directory
sudo mkdir /var/lib/mythtv/db_backups
sudo chmod 777 /var/lib/mythtv/db_backups

It needs to be triggered by the ‘Recording Start’ system event (frontend, setup, system events) which needs to be set to

/usr/bin/ – recording

and also triggered in the /usr/bin/ script which passes next wakeup time to the script and allows it to detect whether it is the last closedown of the 4am to 4am day and perform the database backup.

The setwakeup script is: