Autobackup.sh
Note: The correct title of this article is autobackup.sh. It appears incorrectly here due to technical restrictions.
| Author | Phil Brady |
| Description | Daily database backup at end of day |
| Supports |
THIS PAGE IS UNDER CONSTRUCTION. PLEASE IGNORE IT FOR NOW!
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/autobackup.sh and which calls mythconverg_backup.pl as appropriate. It is called itself from the recording start system event and from within setwakeup.sh
The script can be placed in /usr/bin/autobackup.sh
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/autobackup.sh #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/autobackup.sh – recording
and also triggered in the /usr/bin/setwakeup.sh 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: