MythTV / mythtv

The official MythTV repository
https://www.mythtv.org
GNU General Public License v2.0
700 stars 344 forks source link

Backup and restore script do not take custom DBPort into account #823

Open thomfab opened 8 months ago

thomfab commented 8 months ago

What steps will reproduce the bug?

Use a custom port to access the MySQL/MariaDB database, for example 13306 instead of the standard 3306

setup .mythtv/config.xml with entry: ` 13306

and then try to backup or restore the database. here is the full message :

/usr/share/mythtv/mythconverg_restore.pl --directory /home/mythtv --filename db-backups/mythconverg-20231207183001.sql.gz --verbose

Configuring environment:
  -    username: mythtv
  -        HOME: /home/mythtv
  - MYTHCONFDIR: /home/mythtv/.mythtv

Parsing configuration files:
  - checking: /home/mythtv/.mythtv/config.xml
     parsing: /home/mythtv/.mythtv/config.xml
  - checking: /home/mythtv/.mythtv/backuprc
     parsing: /home/mythtv/.mythtv/backuprc

Applying command-line arguments.

Checking configuration.

Database Information:
         DBHostName: dbserver
             DBPort: 13306
         DBUserName: mythtv
         DBPassword: XXX
             DBName: mythconverg
        DBSchemaVer: 
  DBBackupDirectory: /home/mythtv
   DBBackupFilename: db-backups/mythconverg-20231207183001.sql.gz
      drop_database: no
    create_database: no

Executables:
       mysql_client: mysql
         uncompress: gzip -d

Miscellaneous:
    partial_restore: no
   restore_xmltvids: no
    change_hostname: no

Checking database.

DBI connect('host=dbserver:database=mythconverg','mythtv',...) failed: Can't connect to MySQL server on 'dbserver:3306' (111) at /usr/share/mythtv/mythconverg_restore.pl line 936.

Unable to connect to database.
           database: mythconverg
               host: dbserver
           username: mythtv
           password: mythtv

Please check your configuration files to verify the database connection
information is correct.  The files that are used to retrieve connection
information are prefixed with "parsing" in the "Parsing configuration files"
section of the --verbose output.

Also note that any [client] or [mysql] password specified in the MySQL options
file (/etc/my.cnf or /etc/mysql/my.cnf or ~/.my.cnf) will take precedence over
the password specified in the MythTV configuration files.

ERROR: Unable to connect to database.

mythconverg_restore is ignoring the custom DBPort and therefore fails to connect.

How often does it reproduce? Is there a required condition?

Every time.

What is the expected behaviour?

mythconverg_backup.pl and mythconverg_restore.pl scripts should use the custom DBPort defined.

Here are possible patchs:

diff mythconverg_restore.pl mythconverg_restore_new.pl 
927a928
>         $connect_string .= ":port=$mysql_conf{'db_port'}";
931a933,934
>   verbose($verbose_level_always,
>       " Connection string : $connect_string");
diff mythconverg_backup.pl mythconverg_backup_new.pl 
712a713
>               "port=$mysql_conf{'db_port'}:".

What do you see instead?

Connection error (see above)

Additional information

rcrdnalor commented 8 months ago

Have you looked at #193 ?