diff --git a/src/etc/inc/config.inc b/src/etc/inc/config.inc index 83d5c08a8..ca658039e 100644 --- a/src/etc/inc/config.inc +++ b/src/etc/inc/config.inc @@ -300,6 +300,11 @@ function backup_to_google_drive() if ($cnf->isValid()) { $config = $cnf->object(); if (isset($config->system->remotebackup) && isset($config->system->remotebackup->GDriveEnabled) && $config->system->remotebackup->GDriveEnabled == "on") { + if (!empty($config->system->remotebackup->GDrivePrefixHostname)) { + $fileprefix = (string)$config->system->hostname . "." . (string)$config->system->domain . "-"; + } else { + $fileprefix = "config-"; + } try { $client = new Google\API\Drive(); $client->login($config->system->remotebackup->GDriveEmail->__toString(), @@ -315,7 +320,7 @@ function backup_to_google_drive() tagfile_reformat($confdata_enc, $confdata_enc, "config.xml"); - // read filelist (config-*.xml) + // read filelist ({prefix}*.xml) try { $files = $client->listFiles($config->system->remotebackup->GDriveFolderID->__toString()); } catch (Exception $e) { @@ -325,7 +330,7 @@ function backup_to_google_drive() $configfiles = array(); foreach ($files as $file) { - if (fnmatch("config-*.xml", $file['title'])) { + if (fnmatch("{$fileprefix}*.xml", $file['title'])) { $configfiles[$file['title']] = $file; } } @@ -333,7 +338,7 @@ function backup_to_google_drive() // backup new file if changed (or if first in backup) - $target_filename = "config-" . time() . ".xml"; + $target_filename = $fileprefix . time() . ".xml"; if (count($configfiles) > 1) { // compare last backup with current, only save new try { diff --git a/src/www/diag_backup.php b/src/www/diag_backup.php index 275ef0cf5..9f40b6e85 100644 --- a/src/www/diag_backup.php +++ b/src/www/diag_backup.php @@ -113,6 +113,7 @@ $do_reboot = false; if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig = array(); $pconfig['GDriveEnabled'] = isset($config['system']['remotebackup']['GDriveEnabled']) ? $config['system']['remotebackup']['GDriveEnabled'] : null; + $pconfig['GDrivePrefixHostname'] = isset($config['system']['remotebackup']['GDrivePrefixHostname']) ? $config['system']['remotebackup']['GDrivePrefixHostname'] : null; $pconfig['GDriveEmail'] = isset($config['system']['remotebackup']['GDriveEmail']) ? $config['system']['remotebackup']['GDriveEmail'] : null; $pconfig['GDriveP12key'] = isset($config['system']['remotebackup']['GDriveP12key']) ? $config['system']['remotebackup']['GDriveP12key'] : null; $pconfig['GDriveFolderID'] = isset($config['system']['remotebackup']['GDriveFolderID']) ? $config['system']['remotebackup']['GDriveFolderID'] : null; @@ -253,6 +254,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $config['system']['remotebackup'] = array() ; } $config['system']['remotebackup']['GDriveEnabled'] = $_POST['GDriveEnabled']; + $config['system']['remotebackup']['GDrivePrefixHostname'] = $_POST['GDrivePrefixHostname']; $config['system']['remotebackup']['GDriveEmail'] = $_POST['GDriveEmail'] ; $config['system']['remotebackup']['GDriveFolderID'] = $_POST['GDriveFolderID']; $config['system']['remotebackup']['GDrivePassword'] = $_POST['GDrivePassword']; @@ -471,6 +473,12 @@ $( document ).ready(function() { + + + + > + +