Skip to content

Commit 43189b1

Browse files
author
Marius Burkard
committed
Merge branch '6202-support-for-borg-archive-in-backups' into 'develop'
Add support for borg repositories in backups Closes #6202 See merge request ispconfig/ispconfig3!1526
2 parents 5d05c62 + 600d2c3 commit 43189b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1211
-263
lines changed

interface/lib/classes/plugin_backuplist.inc.php

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ function onShow() {
160160

161161
//* Get the data
162162
$server_ids = array();
163-
$web = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = ?", $this->form->id);
163+
$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);
164164
$databases = $app->db->queryAllRecords("SELECT server_id FROM web_database WHERE parent_domain_id = ?", $this->form->id);
165165
if($app->functions->intval($web['server_id']) > 0) $server_ids[] = $app->functions->intval($web['server_id']);
166166
if(is_array($databases) && !empty($databases)){
@@ -181,8 +181,33 @@ function onShow() {
181181
$rec["bgcolor"] = $bgcolor;
182182

183183
$rec['date'] = date($app->lng('conf_format_datetime'), $rec['tstamp']);
184+
184185
$backup_format = $rec['backup_format'];
185-
if (empty($backup_format)) {
186+
$backup_mode = $rec['backup_mode'];
187+
if ($backup_mode === 'borg') {
188+
// Get backup format from domain config
189+
switch ($rec['backup_type']) {
190+
case 'mysql':
191+
$backup_format = $web['backup_format_db'];
192+
if (empty($backup_format) || $backup_format == 'default') {
193+
$backup_format = self::getDefaultBackupFormat('rootgz', 'mysql');
194+
}
195+
$rec['filename'] .= self::getBackupDbExtension($backup_format);
196+
break;
197+
case 'web':
198+
$backup_format = $web['backup_format_web'];
199+
if (empty($backup_format) || $backup_format == 'default') {
200+
$backup_format = self::getDefaultBackupFormat($backup_mode, 'web');
201+
}
202+
$rec['filename'] .= self::getBackupWebExtension($backup_format);
203+
break;
204+
default:
205+
$app->log('Unsupported backup type "' . $rec['backup_type'] . '" for backup id ' . $rec['backup_id'], LOGLEVEL_ERROR);
206+
break;
207+
}
208+
$rec['backup_password'] = $web['backup_encrypt'] == 'y' ? trim($web['backup_password']) : '';
209+
210+
} elseif (empty($backup_format)) {
186211
//We have a backup from old version of ISPConfig
187212
switch ($rec['backup_type']) {
188213
case 'mysql':
@@ -210,7 +235,13 @@ function onShow() {
210235
if($rec['server_id'] != $web['server_id']) $rec['download_available'] = false;
211236

212237
if($rec['filesize'] > 0){
213-
$rec['filesize'] = $app->functions->currency_format($rec['filesize']/(1024*1024), 'client').' MB';
238+
$rec['filesize'] = $app->functions->currency_format($rec['filesize']/(1024*1024), 'client').' MB';
239+
if($backup_mode === "borg") {
240+
$rec['filesize'] = '<a href="javascript:void(0)" data-toggle="tooltip" title="'
241+
. $wb['final_size_txt']
242+
. '"><strong>*</strong></a>'
243+
. $rec['filesize'];
244+
}
214245
}
215246

216247
$records_new[] = $rec;
@@ -235,6 +266,73 @@ function onShow() {
235266
return $listTpl->grab();
236267
}
237268

269+
/**
270+
* Returns file extension for specified backup format
271+
* @param string $format backup format
272+
* @return string|null
273+
* @author Ramil Valitov <ramilvalitov@gmail.com>
274+
*/
275+
protected static function getBackupDbExtension($format)
276+
{
277+
$prefix = '.sql';
278+
switch ($format) {
279+
case 'gzip':
280+
return $prefix . '.gz';
281+
case 'bzip2':
282+
return $prefix . '.bz2';
283+
case 'xz':
284+
return $prefix . '.xz';
285+
case 'zip':
286+
case 'zip_bzip2':
287+
return '.zip';
288+
case 'rar':
289+
return '.rar';
290+
}
291+
if (strpos($format, "7z_") === 0) {
292+
return $prefix . '.7z';
293+
}
294+
return null;
295+
}
296+
297+
/**
298+
* Returns file extension for specified backup format
299+
* @param string $format backup format
300+
* @return string|null
301+
* @author Ramil Valitov <ramilvalitov@gmail.com>
302+
*/
303+
protected static function getBackupWebExtension($format)
304+
{
305+
switch ($format) {
306+
case 'tar_gzip':
307+
return '.tar.gz';
308+
case 'tar_bzip2':
309+
return '.tar.bz2';
310+
case 'tar_xz':
311+
return '.tar.xz';
312+
case 'zip':
313+
case 'zip_bzip2':
314+
return '.zip';
315+
case 'rar':
316+
return '.rar';
317+
}
318+
if (strpos($format, "tar_7z_") === 0) {
319+
return '.tar.7z';
320+
}
321+
return null;
322+
}
323+
324+
protected static function getDefaultBackupFormat($backup_mode, $backup_type)
325+
{
326+
//We have a backup from old version of ISPConfig
327+
switch ($backup_type) {
328+
case 'mysql':
329+
return 'gzip';
330+
case 'web':
331+
return ($backup_mode == 'userzip') ? 'zip' : 'tar_gzip';
332+
}
333+
return "";
334+
}
335+
238336
}
239337

240338
?>

interface/web/admin/form/server_config.tform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
'datatype' => 'VARCHAR',
208208
'formtype' => 'SELECT',
209209
'default' => 'userzip',
210-
'value' => array('userzip' => 'backup_mode_userzip', 'rootgz' => 'backup_mode_rootgz'),
210+
'value' => array('userzip' => 'backup_mode_userzip', 'rootgz' => 'backup_mode_rootgz', 'borg' => 'backup_mode_borg_txt'),
211211
'width' => '40',
212212
'maxlength' => '255'
213213
),

interface/web/admin/lib/lang/ar_server_config.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ $wb['website_autoalias_note_txt'] = 'Placeholders:';
176176
$wb['backup_mode_txt'] = 'Backup mode';
177177
$wb['backup_mode_userzip'] = 'Backup web files owned by web user as zip';
178178
$wb['backup_mode_rootgz'] = 'Backup all files in web directory as root user';
179+
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
180+
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
179181
$wb['realtime_blackhole_list_txt'] = 'Real-time Blackhole List';
180182
$wb['realtime_blackhole_list_note_txt'] = '(Separate RBL\'s with commas)';
181183
$wb['stress_adaptive_txt'] = 'Adapt to temporary load spikes';

interface/web/admin/lib/lang/bg_server_config.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ $wb['connect_userid_to_webid_start_txt'] = 'Start ID for userid/webid connect';
174174
$wb['backup_mode_txt'] = 'Backup mode';
175175
$wb['backup_mode_userzip'] = 'Backup web files owned by web user as zip';
176176
$wb['backup_mode_rootgz'] = 'Backup all files in web directory as root user';
177+
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
178+
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
177179
$wb['realtime_blackhole_list_txt'] = 'Real-time Blackhole List';
178180
$wb['realtime_blackhole_list_note_txt'] = '(Separate RBL\'s with commas)';
179181
$wb['stress_adaptive_txt'] = 'Adapt to temporary load spikes';

interface/web/admin/lib/lang/br_server_config.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ $wb['fastcgi_config_syntax_txt'] = 'Sintaxe das configurações do FastCGI';
114114
$wb['backup_mode_txt'] = 'Modo do backup';
115115
$wb['backup_mode_userzip'] = 'Arquivos de backup com propriedade do usuário web e compactados como zip';
116116
$wb['backup_mode_rootgz'] = 'Todos os arquivos no diretório web com proprietário root';
117+
$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';
118+
$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:';
117119
$wb['tmpdir_path_error_empty'] = 'Caminho do diretório temporário está vazio.';
118120
$wb['tmpdir_path_error_regex'] = 'Caminho do diretório temporário é inválido.';
119121
$wb['backup_time_txt'] = 'Hora do backup';

interface/web/admin/lib/lang/ca_server_config.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ $wb['fastcgi_config_syntax_txt'] = 'FastCGI config syntax';
113113
$wb['backup_mode_txt'] = 'Backup mode';
114114
$wb['backup_mode_userzip'] = 'Backup web files owned by web user as zip';
115115
$wb['backup_mode_rootgz'] = 'Backup all files in web directory as root user';
116+
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
117+
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
116118
$wb['server_type_txt'] = 'Server Type';
117119
$wb['nginx_vhost_conf_dir_txt'] = 'Nginx Vhost config dir';
118120
$wb['nginx_vhost_conf_enabled_dir_txt'] = 'Nginx Vhost config enabled dir';

interface/web/admin/lib/lang/cz_server_config.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ $wb['website_autoalias_note_txt'] = 'Placeholders:';
162162
$wb['backup_mode_txt'] = 'Režim zálohování';
163163
$wb['backup_mode_userzip'] = 'Zálohování všech souborů v adresáři web jako uživatel vlastnící web adresář do souboru zip';
164164
$wb['backup_mode_rootgz'] = 'Zálohování všech souborů v adresáři web jako uživatel root';
165+
$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šť';
166+
$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:';
165167
$wb['realtime_blackhole_list_txt'] = 'Real-time Blackhole List';
166168
$wb['realtime_blackhole_list_note_txt'] = '(jednotlivé RBL databáze oddělujte čárkou)';
167169
$wb['stress_adaptive_txt'] = 'Adapt to temporary load spikes';

interface/web/admin/lib/lang/de_server_config.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ $wb['awstats_settings_txt'] = 'AWStats Einstellungen';
190190
$wb['backup_mode_txt'] = 'Backupmodus';
191191
$wb['backup_mode_userzip'] = 'Backup Dateien gehören dem Web Benutzer (.zip Datei)';
192192
$wb['backup_mode_rootgz'] = 'Backup aller Dateien des Webverzeichnisses als Root Benutzer';
193+
$wb['backup_mode_borg_txt'] = 'BorgBackup: Maak een back-up van alle bestanden in de vhost-directory en databases in incrementele repositories';
194+
$wb['backup_missing_utils_txt'] = 'De volgende back-upmodus kan niet worden gebruikt omdat de vereiste tools niet zijn geïnstalleerd:';
193195
$wb['backup_time_txt'] = 'Backupzeit';
194196
$wb['firewall_txt'] = 'Firewall';
195197
$wb['mailbox_quota_stats_txt'] = 'E-Mailkonto Beschränkung Statistiken';

interface/web/admin/lib/lang/dk_server_config.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ $wb['fastcgi_config_syntax_txt'] = 'FastCGI config syntax';
100100
$wb['backup_mode_txt'] = 'Backup mode';
101101
$wb['backup_mode_userzip'] = 'Backup webfiler ejet af web-bruger som zip';
102102
$wb['backup_mode_rootgz'] = 'Backup alle filer i web mappe som root-bruger';
103+
$wb['backup_mode_borg_txt'] = 'BorgBackup: Sikkerhedskopier alle filer i vhost -bibliotek og databaser til inkrementelle lagre';
104+
$wb['backup_missing_utils_txt'] = 'Følgende backup -tilstand kan ikke bruges, fordi de nødvendige værktøjer ikke er installeret:';
103105
$wb['server_type_txt'] = 'Server Type';
104106
$wb['nginx_vhost_conf_dir_txt'] = 'Nginx Vhost config dir';
105107
$wb['nginx_vhost_conf_enabled_dir_txt'] = 'Nginx Vhost config enabled dir';

interface/web/admin/lib/lang/el_server_config.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ $wb['website_autoalias_note_txt'] = 'Placeholders:';
176176
$wb['backup_mode_txt'] = 'Backup mode';
177177
$wb['backup_mode_userzip'] = 'Backup web files owned by web user as zip';
178178
$wb['backup_mode_rootgz'] = 'Backup all files in web directory as root user';
179+
$wb['backup_mode_borg_txt'] = 'BorgBackup: Backup all files in vhost directory and databases into incremental repositories';
180+
$wb['backup_missing_utils_txt'] = 'The following backup mode can not be used because the required tools are not installed:';
179181
$wb['realtime_blackhole_list_txt'] = 'Real-time Blackhole List';
180182
$wb['realtime_blackhole_list_note_txt'] = '(Separate RBL\'s with commas)';
181183
$wb['stress_adaptive_txt'] = 'Adapt to temporary load spikes';

0 commit comments

Comments
 (0)