Database backup settings not in sync with parent website
short description
What is happening and what is wrong with that?
Fields 'backup_interval' and 'backup_copies' in table 'web_database' are set to none/1 on database creation and are not updated when its parent website backup settings are changed.
As a sideeffect this effectivley breaks the backup cronjob. It will backup webroot directory and database, but the database backup cleanup job looks at the web_database.backup_copies value and sees that there should only a single backup copy, so it delete all webroot and database backups, aside from the last one.
correct behaviour
What should happen instead?
Fields in web_database should be in sync with the values set for its parent website.
environment
Server OS: Ubuntu Server OS version: 20.04 ISPConfig version: 3.1dev
proposed fix
It seems that the queries for keeping the values in sync are broken, due to them referencing 'backup_format_db' and 'backup_format_web' which do not exist in 'web_database' table. As a quickfix removing both references from the queries seems to work.
In sites_web_vhost_domain_plugin.inc.php#L268 change
$app->db->datalogUpdate('web_database', array("backup_interval" => $backup_interval, "backup_copies" => $backup_copies, "backup_format_web" => $backup_format_web, "backup_format_db" => $backup_format_db), 'database_id', $rec['database_id']);
to
$app->db->datalogUpdate('web_database', array("backup_interval" => $backup_interval, "backup_copies" => $backup_copies), 'database_id', $rec['database_id']);
and in sites_database_plugin.inc.php#L52 change
$sql = "UPDATE web_database SET sys_groupid = ?, backup_interval = ?, backup_copies = ?, backup_format_web = ?, backup_format_db = ? WHERE database_id = ?";
$app->db->query($sql, $sys_groupid, $backup_interval, $backup_copies, $backup_format_web, $backup_format_db, $form_page->id);
to
$sql = "UPDATE web_database SET sys_groupid = ?, backup_interval = ?, backup_copies = ? WHERE database_id = ?";
$app->db->query($sql, $sys_groupid, $backup_interval, $backup_copies, $form_page->id);