Database Replace Recordings
Contents
Scenario:
A mythconverg database backup is restored. The 'Watch Recordings' list is invalid. The steps below may allow one to restore recording information from a more current backup. The procedure below uses backups created via the mythconverg_backup.pl script.
Warning:
- Backup Everything First! (especially your database using mythconverg_backup.pl)
The database schema changes. Restoring SQL tables between different schemas may or may not work. As currently implemented, the schema version is listed in the backup filename. For instance, file mythconverg-1314-20130717202040.sql.gz uses schema 1314.
- Work with a nonproduction machine if possible.
- Know how to backup and restore the mythconverg database using the Mythtv provided scripts before proceeding.
Substitute your file names in the steps below. It is assumed an old backup database has been restored and is operating nominally. You wish to restore recorded program data from a more recent backup.
Unzip the backup containing the desired recorded program information
gzip -d -c mythconverg-1323-20140303103640.sql.gz > /tmp/mythconverg-1323-20140303103640.sql
Extract the 'recorded' SQL table
From a terminal window:
vim /tmp/mythconverg-1323-20140303103640.sql
Find the start of the 'recorded' SQL table. For instance...
-- -- Table structure for table `recorded` --
Place the cursor on the first '--' line and note the line number displayed in the lower right (scroll lines if necessary to confirm you know which number is the line number). If the line number is 2660 and your cursor is below that line:
:d1,2660
will delete from the beginning of the file to line 2660 inclusive.
Move the cursor down to the line beginning with:
INSERT INTO `recorded
and strike the [End] key to go to the end of the line. Scroll the cursor down past the following '--' line and type
dG (no leading colon)
to delete the end of the file. Save the file (:wq).
Stop your mythbackend
Stop your mythbackend in the manner suggested by your distribution.
Check the mythconverg database
At the time of this writing, the following check works when run from a terminal window as user 'mysql':
myisamchk --silent --fast //var/lib/mysql/mythconverg/*.MYI
It is an exercise for the reader to investigate and execute any procedure to repair any SQL table errors found.
Replace the current 'recorded' SQL table
Assuming the vim edit went well, the following command (as user 'mythtv') should simply return a prompt after the password is entered:
mysql -p -u mythtv mythconverg < /tmp/mythconverg-1323-20140303103640.sql
Start your backend and check your work
Restart the mythbackend. Start a mythfrontend client. The 'Watch Recordings' listing should now display the program listing from the 'vim edited' backup.