Commit 4cd48685 authored by Jorge Muñoz's avatar Jorge Muñoz
Browse files

Add support for borgbackup incremental backups

parent 36cdb858
Pipeline #9545 passed with stage
in 8 minutes and 19 seconds
......@@ -160,7 +160,7 @@ class plugin_backuplist extends plugin_base {
//* Get the data
$server_ids = array();
$web = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = ?", $this->form->id);
$web = $app->db->queryOneRecord("SELECT server_id, backup_format_web, backup_format_db, backup_password, backup_encrypt FROM web_domain WHERE domain_id = ?", $this->form->id);
$databases = $app->db->queryAllRecords("SELECT server_id FROM web_database WHERE parent_domain_id = ?", $this->form->id);
if($app->functions->intval($web['server_id']) > 0) $server_ids[] = $app->functions->intval($web['server_id']);
if(is_array($databases) && !empty($databases)){
......@@ -181,8 +181,33 @@ class plugin_backuplist extends plugin_base {
$rec["bgcolor"] = $bgcolor;
$rec['date'] = date($app->lng('conf_format_datetime'), $rec['tstamp']);
$backup_format = $rec['backup_format'];
if (empty($backup_format)) {
$backup_mode = $rec['backup_mode'];
if ($backup_mode == 'borg') {
// Get backup format from domain config
switch ($rec['backup_type']) {
case 'mysql':
$backup_format = $web['backup_format_db'];
if (empty($backup_format) || $backup_format == 'default') {
$backup_format = self::getDefaultBackupFormat('rootgz', 'mysql');
}
$rec['filename'] .= self::getBackupDbExtension($backup_format);
break;
case 'web':
$backup_format = $web['backup_format_web'];
if (empty($backup_format) || $backup_format == 'default') {
$backup_format = self::getDefaultBackupFormat($backup_mode, 'web');
}
$rec['filename'] .= self::getBackupWebExtension($backup_format);
break;
default:
$app->log('Unsupported backup type "' . $rec['backup_type'] . '" for backup id ' . $rec['backup_id'], LOGLEVEL_ERROR);
break;
}
$rec['backup_password'] = $web['backup_encrypt'] == 'y' ? trim($web['backup_password']) : '';
} elseif (empty($backup_format)) {
//We have a backup from old version of ISPConfig
switch ($rec['backup_type']) {
case 'mysql':
......@@ -210,7 +235,13 @@ class plugin_backuplist extends plugin_base {
if($rec['server_id'] != $web['server_id']) $rec['download_available'] = false;
if($rec['filesize'] > 0){
$rec['filesize'] = $app->functions->currency_format($rec['filesize']/(1024*1024), 'client').' MB';
$rec['filesize'] = $app->functions->currency_format($rec['filesize']/(1024*1024), 'client').' MB';
if($backup_mode == "borg") {
$rec['filesize'] = '<a href="javascript:void(0)" data-toggle="tooltip" title="'
. $wb['final_size_txt']
. '"><strong>*</strong></a>'
. $rec['filesize'];
}
}
$records_new[] = $rec;
......@@ -235,6 +266,72 @@ class plugin_backuplist extends plugin_base {
return $listTpl->grab();
}
/**
* Returns file extension for specified backup format
* @param string $format backup format
* @return string|null
* @author Ramil Valitov <ramilvalitov@gmail.com>
*/
protected static function getBackupDbExtension($format)
{
$prefix = '.sql';
switch ($format) {
case 'gzip':
return $prefix . '.gz';
case 'bzip2':
return $prefix . '.bz2';
case 'xz':
return $prefix . '.xz';
case 'zip':
case 'zip_bzip2':
return '.zip';
case 'rar':
return '.rar';
}
if (strpos($format, "7z_") === 0) {
return $prefix . '.7z';
}
return null;
}
/**
* Returns file extension for specified backup format
* @param string $format backup format
* @return string|null
* @author Ramil Valitov <ramilvalitov@gmail.com>
*/
protected static function getBackupWebExtension($format)
{
switch ($format) {
case 'tar_gzip':
return '.tar.gz';
case 'tar_bzip2':
return '.tar.bz2';
case 'tar_xz':
return '.tar.xz';
case 'zip':
case 'zip_bzip2':
return '.zip';
case 'rar':
return '.rar';
}
if (strpos($format, "tar_7z_") === 0) {
return '.tar.7z';
}
return null;
}
protected static function getDefaultBackupFormat($backup_mode, $backup_type)
{
//We have a backup from old version of ISPConfig
switch ($backup_type) {
case 'mysql':
return 'gzip';
case 'web':
return ($backup_mode == 'userzip') ? 'zip' : 'tar_gzip';
}
return "";
}
}
?>
......@@ -207,7 +207,7 @@ $form["tabs"]['server'] = array(
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => 'userzip',
'value' => array('userzip' => 'backup_mode_userzip', 'rootgz' => 'backup_mode_rootgz'),
'value' => array('userzip' => 'backup_mode_userzip', 'rootgz' => 'backup_mode_rootgz', 'borg' => 'backup_mode_borg_txt'),
'width' => '40',
'maxlength' => '255'
),
......
......@@ -176,6 +176,8 @@ $wb['website_autoalias_note_txt'] = 'Placeholders:';
$wb['backup_mode_txt'] = 'Backup mode';
$wb['backup_mode_userzip'] = 'Backup web files owned by web user as zip';
$wb['backup_mode_rootgz'] = 'Backup all files in web directory as root user';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
$wb['realtime_blackhole_list_txt'] = 'Real-time Blackhole List';
$wb['realtime_blackhole_list_note_txt'] = '(Separate RBL\'s with commas)';
$wb['stress_adaptive_txt'] = 'Adapt to temporary load spikes';
......
......@@ -174,6 +174,8 @@ $wb['connect_userid_to_webid_start_txt'] = 'Start ID for userid/webid connect';
$wb['backup_mode_txt'] = 'Backup mode';
$wb['backup_mode_userzip'] = 'Backup web files owned by web user as zip';
$wb['backup_mode_rootgz'] = 'Backup all files in web directory as root user';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
$wb['realtime_blackhole_list_txt'] = 'Real-time Blackhole List';
$wb['realtime_blackhole_list_note_txt'] = '(Separate RBL\'s with commas)';
$wb['stress_adaptive_txt'] = 'Adapt to temporary load spikes';
......
......@@ -114,6 +114,8 @@ $wb['fastcgi_config_syntax_txt'] = 'Sintaxe das configurações do FastCGI';
$wb['backup_mode_txt'] = 'Modo do backup';
$wb['backup_mode_userzip'] = 'Arquivos de backup com propriedade do usuário web e compactados como zip';
$wb['backup_mode_rootgz'] = 'Todos os arquivos no diretório web com proprietário root';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Faça backup de todos os arquivos no diretório vhost e bancos de dados em repositórios incrementais';
$wb['backup_missing_utils_txt'] = 'O seguinte modo de backup não pode ser usado porque as ferramentas necessárias não estão instaladas:';
$wb['tmpdir_path_error_empty'] = 'Caminho do diretório temporário está vazio.';
$wb['tmpdir_path_error_regex'] = 'Caminho do diretório temporário é inválido.';
$wb['backup_time_txt'] = 'Hora do backup';
......
......@@ -113,6 +113,8 @@ $wb['fastcgi_config_syntax_txt'] = 'FastCGI config syntax';
$wb['backup_mode_txt'] = 'Backup mode';
$wb['backup_mode_userzip'] = 'Backup web files owned by web user as zip';
$wb['backup_mode_rootgz'] = 'Backup all files in web directory as root user';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
$wb['server_type_txt'] = 'Server Type';
$wb['nginx_vhost_conf_dir_txt'] = 'Nginx Vhost config dir';
$wb['nginx_vhost_conf_enabled_dir_txt'] = 'Nginx Vhost config enabled dir';
......
......@@ -162,6 +162,8 @@ $wb['website_autoalias_note_txt'] = 'Placeholders:';
$wb['backup_mode_txt'] = 'Režim zálohování';
$wb['backup_mode_userzip'] = 'Zálohování všech souborů v adresáři web jako uživatel vlastnící web adresář do souboru zip';
$wb['backup_mode_rootgz'] = 'Zálohování všech souborů v adresáři web jako uživatel root';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Zálohujte všechny soubory v adresáři vhost a databázích do přírůstkových úložišť';
$wb['backup_missing_utils_txt'] = 'Následující režim zálohování nelze použít, protože nejsou nainstalovány požadované nástroje:';
$wb['realtime_blackhole_list_txt'] = 'Real-time Blackhole List';
$wb['realtime_blackhole_list_note_txt'] = '(jednotlivé RBL databáze oddělujte čárkou)';
$wb['stress_adaptive_txt'] = 'Adapt to temporary load spikes';
......
......@@ -190,6 +190,8 @@ $wb['awstats_settings_txt'] = 'AWStats Einstellungen';
$wb['backup_mode_txt'] = 'Backupmodus';
$wb['backup_mode_userzip'] = 'Backup Dateien gehören dem Web Benutzer (.zip Datei)';
$wb['backup_mode_rootgz'] = 'Backup aller Dateien des Webverzeichnisses als Root Benutzer';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Maak een back-up van alle bestanden in de vhost-directory en databases in incrementele repositories';
$wb['backup_missing_utils_txt'] = 'De volgende back-upmodus kan niet worden gebruikt omdat de vereiste tools niet zijn geïnstalleerd:';
$wb['backup_time_txt'] = 'Backupzeit';
$wb['firewall_txt'] = 'Firewall';
$wb['mailbox_quota_stats_txt'] = 'E-Mailkonto Beschränkung Statistiken';
......
......@@ -100,6 +100,8 @@ $wb['fastcgi_config_syntax_txt'] = 'FastCGI config syntax';
$wb['backup_mode_txt'] = 'Backup mode';
$wb['backup_mode_userzip'] = 'Backup webfiler ejet af web-bruger som zip';
$wb['backup_mode_rootgz'] = 'Backup alle filer i web mappe som root-bruger';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Sikkerhedskopier alle filer i vhost -bibliotek og databaser til inkrementelle lagre';
$wb['backup_missing_utils_txt'] = 'Følgende backup -tilstand kan ikke bruges, fordi de nødvendige værktøjer ikke er installeret:';
$wb['server_type_txt'] = 'Server Type';
$wb['nginx_vhost_conf_dir_txt'] = 'Nginx Vhost config dir';
$wb['nginx_vhost_conf_enabled_dir_txt'] = 'Nginx Vhost config enabled dir';
......
......@@ -176,6 +176,8 @@ $wb['website_autoalias_note_txt'] = 'Placeholders:';
$wb['backup_mode_txt'] = 'Backup mode';
$wb['backup_mode_userzip'] = 'Backup web files owned by web user as zip';
$wb['backup_mode_rootgz'] = 'Backup all files in web directory as root user';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
$wb['realtime_blackhole_list_txt'] = 'Real-time Blackhole List';
$wb['realtime_blackhole_list_note_txt'] = '(Separate RBL\'s with commas)';
$wb['stress_adaptive_txt'] = 'Adapt to temporary load spikes';
......
......@@ -120,6 +120,8 @@ $wb['fastcgi_config_syntax_txt'] = 'FastCGI config syntax';
$wb['backup_mode_txt'] = 'Backup mode';
$wb['backup_mode_userzip'] = 'Backup web files owned by web user as zip';
$wb['backup_mode_rootgz'] = 'Backup all files in web directory as root user';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
$wb['tmpdir_path_error_empty'] = 'tmp-dir Path is empty.';
$wb['tmpdir_path_error_regex'] = 'Invalid tmp-dir path.';
$wb['backup_time_txt'] = 'Backup time';
......
......@@ -36,6 +36,8 @@ $wb['backup_dir_is_mount_txt'] = 'El directorio de copias de seguridad está mon
$wb['backup_dir_mount_cmd_txt'] = 'Comando de montaje, si el directorio de copias de seguridad no está montado';
$wb['backup_dir_txt'] = 'Directorio para respaldos';
$wb['backup_mode_rootgz'] = 'Respaldar todos los archivos en el directorio web siendo root el propietario';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Respaldar todos los archivos en el directorio vhost y las bases de datos en repositorios incrementales';
$wb['backup_missing_utils_txt'] = 'El siguiente modo de respaldo no se puede utilizar porque las herramientas necesarias no están instaladas:';
$wb['backup_mode_txt'] = 'Modo de respaldo';
$wb['backup_mode_userzip'] = 'Respaldar archivos web siendo el usuario el propietario en formato zip';
$wb['bind_group_error_empty'] = 'El grupo para BIND está vacío.';
......
......@@ -176,6 +176,8 @@ $wb['website_autoalias_note_txt'] = 'Placeholders:';
$wb['backup_mode_txt'] = 'Backup mode';
$wb['backup_mode_userzip'] = 'Backup web files owned by web user as zip';
$wb['backup_mode_rootgz'] = 'Backup all files in web directory as root user';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
$wb['realtime_blackhole_list_txt'] = 'Real-time Blackhole List';
$wb['realtime_blackhole_list_note_txt'] = '(Separate RBL\'s with commas)';
$wb['stress_adaptive_txt'] = 'Adapt to temporary load spikes';
......
......@@ -164,6 +164,8 @@ $wb['website_autoalias_note_txt'] = 'Placeholders:';
$wb['backup_mode_txt'] = 'Backup mode';
$wb['backup_mode_userzip'] = 'Backup web files owned by web user as zip';
$wb['backup_mode_rootgz'] = 'Backup all files in web directory as root user';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
$wb['realtime_blackhole_list_txt'] = 'Real-time Blackhole List';
$wb['realtime_blackhole_list_note_txt'] = '(Separate RBL’s with commas)';
$wb['stress_adaptive_txt'] = 'Adapt to temporary load spikes';
......
......@@ -176,6 +176,8 @@ $wb['website_autoalias_note_txt'] = 'Placeholders:';
$wb['backup_mode_txt'] = 'Backup mode';
$wb['backup_mode_userzip'] = 'Backup web files owned by web user as zip';
$wb['backup_mode_rootgz'] = 'Backup all files in web directory as root user';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
$wb['realtime_blackhole_list_txt'] = 'Real-time Blackhole List';
$wb['realtime_blackhole_list_note_txt'] = '(Separate RBL\'s with commas)';
$wb['stress_adaptive_txt'] = 'Adapt to temporary load spikes';
......
......@@ -176,6 +176,8 @@ $wb['website_autoalias_note_txt'] = 'Placeholders:';
$wb['backup_mode_txt'] = 'Backup mode';
$wb['backup_mode_userzip'] = 'Backup web files owned by web user as zip';
$wb['backup_mode_rootgz'] = 'Backup all files in web directory as root user';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
$wb['realtime_blackhole_list_txt'] = 'Real-time Blackhole List';
$wb['realtime_blackhole_list_note_txt'] = '(Separate RBL\'s with commas)';
$wb['stress_adaptive_txt'] = 'Adapt to temporary load spikes';
......
......@@ -176,6 +176,8 @@ $wb['website_autoalias_note_txt'] = 'Placeholders:';
$wb['backup_mode_txt'] = 'Backup mode';
$wb['backup_mode_userzip'] = 'Backup web files owned by web user as zip';
$wb['backup_mode_rootgz'] = 'Backup all files in web directory as root user';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
$wb['realtime_blackhole_list_txt'] = 'Real-time Blackhole List';
$wb['realtime_blackhole_list_note_txt'] = '(Separate RBL\'s with commas)';
$wb['stress_adaptive_txt'] = 'Adapt to temporary load spikes';
......
......@@ -164,6 +164,8 @@ $wb['website_autoalias_note_txt'] = 'Placeholders:';
$wb['backup_mode_txt'] = 'Modalità di Backup';
$wb['backup_mode_userzip'] = 'Backup files siti web come utente web in formato zip';
$wb['backup_mode_rootgz'] = 'Backup di tutti i files nella cartella sito come utente root';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
$wb['realtime_blackhole_list_txt'] = 'Lista Real-Time Blackhole';
$wb['realtime_blackhole_list_note_txt'] = '(Separare RBL con le virgole)';
$wb['stress_adaptive_txt'] = 'Adapt to temporary load spikes';
......
......@@ -176,6 +176,8 @@ $wb['website_autoalias_note_txt'] = 'Placeholders:';
$wb['backup_mode_txt'] = 'Backup mode';
$wb['backup_mode_userzip'] = 'Backup web files owned by web user as zip';
$wb['backup_mode_rootgz'] = 'Backup all files in web directory as root user';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
$wb['realtime_blackhole_list_txt'] = 'Real-time Blackhole List';
$wb['realtime_blackhole_list_note_txt'] = '(Separate RBL\'s with commas)';
$wb['stress_adaptive_txt'] = 'Adapt to temporary load spikes';
......
......@@ -176,6 +176,8 @@ $wb['website_autoalias_note_txt'] = 'Placeholders:';
$wb['backup_mode_txt'] = 'Backup mode';
$wb['backup_mode_userzip'] = 'Backup web files owned by web user as zip';
$wb['backup_mode_rootgz'] = 'Backup all files in web directory as root user';
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
$wb['realtime_blackhole_list_txt'] = 'Real-time Blackhole List';
$wb['realtime_blackhole_list_note_txt'] = '(Separate RBL\'s with commas)';
$wb['stress_adaptive_txt'] = 'Adapt to temporary load spikes';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment