Skip to content

Commit fd0a96b

Browse files
Alexandros Ioannidesjaapmarcus
andauthored
Make ZSTD multi-threaded (hestiacp#1593)
* Multi-threaded compression for zstd * Update CHANGELOG.md * Multi threaded zstd * Multi-threaded decompression for ZSTD * Added 10 - 19 “Compression” level Added link to docs. * Set “Default” for new users to 4 Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com>
1 parent f0587fc commit fd0a96b

File tree

8 files changed

+33
-27
lines changed

8 files changed

+33
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file.
1313
- Fixed an issue where local and FTP backup files were not deleted when running `v-delete-user-backup`. (#1421)
1414
- Fixed an issue where IP addresses could not be deleted (#1423)
1515
- Improvements have been made to the API's error handling - thanks **@danielalexis**!
16+
- ZSTD Compression has been made multi-threaded.
1617

1718
## [1.3.2] - Service Release
1819
### Features

bin/v-backup-user

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
271271

272272
# Backup files
273273
if [ "$BACKUP_MODE" = 'zstd' ]; then
274-
tar ${fargs[@]} -cpf- * | zstd -$BACKUP_GZIP - > $tmpdir/web/$domain/domain_data.tar.zst
274+
tar ${fargs[@]} -cpf- * | pzstd -$BACKUP_GZIP - > $tmpdir/web/$domain/domain_data.tar.zst
275275
else
276276
tar ${fargs[@]} -cpf- * | gzip -$BACKUP_GZIP - > $tmpdir/web/$domain/domain_data.tar.gz
277277
fi
@@ -390,7 +390,7 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
390390
# Compress archive
391391
if [ ${#accounts[@]} -gt 0 ]; then
392392
if [ "$BACKUP_MODE" = 'zstd' ]; then
393-
tar -cpf- ${accounts[@]} | zstd -$BACKUP_GZIP - > $tmpdir/mail/$domain/accounts.tar.zst
393+
tar -cpf- ${accounts[@]} | pzstd -$BACKUP_GZIP - > $tmpdir/mail/$domain/accounts.tar.zst
394394
else
395395
tar -cpf- ${accounts[@]} | gzip -$BACKUP_GZIP - > $tmpdir/mail/$domain/accounts.tar.gz
396396
fi
@@ -470,7 +470,7 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB" != '*' ]; then
470470

471471
# Compress dump
472472
if [ "$BACKUP_MODE" = 'zstd' ]; then
473-
zstd -$BACKUP_GZIP $dump
473+
pzstd -$BACKUP_GZIP $dump
474474
rm $dump;
475475
else
476476
gzip -$BACKUP_GZIP $dump
@@ -551,7 +551,7 @@ if [ "$USER" != '*' ]; then
551551

552552
# Backup files and dirs
553553
if [ "$BACKUP_MODE" = 'zstd' ]; then
554-
tar --anchored -cpf- ${fargs[@]} $udir | zstd -$BACKUP_GZIP - > $tmpdir/user_dir/$udir.tar.zst
554+
tar --anchored -cpf- ${fargs[@]} $udir | pzstd -$BACKUP_GZIP - > $tmpdir/user_dir/$udir.tar.zst
555555
else
556556
tar --anchored -cpf- ${fargs[@]} $udir | gzip -$BACKUP_GZIP - > $tmpdir/user_dir/$udir.tar.gz
557557
fi

bin/v-extract-fs-archive

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ if [ ! -z "$(echo $src_file |egrep -i '.tar.zst')" ]; then
9090
x='yes'
9191
if [ -z "$test" ] || [ "$test" = "no" ]; then
9292
user_exec mkdir -p "$dst_dir" >/dev/null 2>&1
93-
user_exec tar -I zstd -xf "$src_file" -C "$dst_dir" --no-wildcards "$selected_dir" $tar_strip_level >/dev/null 2>&1
93+
user_exec tar -I pzstd -xf "$src_file" -C "$dst_dir" --no-wildcards "$selected_dir" $tar_strip_level >/dev/null 2>&1
9494
rc=$?
9595
else
96-
user_exec tar -I zstd -tf "$src_file" --no-wildcards "$selected_dir" >/dev/null 2>&1
96+
user_exec tar -I pzstd -tf "$src_file" --no-wildcards "$selected_dir" >/dev/null 2>&1
9797
rc=$?
9898
fi
9999
fi
@@ -102,7 +102,7 @@ fi
102102
if [ ! -z "$(echo $src_file |grep -i '.zst')" ] && [ -z "$x" ]; then
103103
user_exec mkdir -p "$dst_dir" >/dev/null 2>&1
104104
user_exec mv "$src_file" "$dst_dir" >/dev/null 2>&1
105-
user_exec zstd -d "$dst_dir/$(basename $src_file)" >/dev/null 2>&1
105+
user_exec pzstd -d "$dst_dir/$(basename $src_file)" >/dev/null 2>&1
106106
rc=$?
107107
fi
108108

bin/v-restore-user

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ if [ "$web" != 'no' ] && [ ! -z "$WEB_SYSTEM" ]; then
330330
[[ -d $HOMEDIR/$user/web/$domain/stats ]] && chmod u+w "$HOMEDIR/$user/web/$domain/stats"
331331

332332
if [ "$backup_mode" = "zstd" ]; then
333-
user_exec tar -I zstd -xpf $tmpdir/web/$domain/domain_data.tar.zst \
333+
user_exec tar -I pzstd -xpf $tmpdir/web/$domain/domain_data.tar.zst \
334334
-C "$HOMEDIR/$user/web/$domain/" \
335335
--anchored \
336336
--exclude='logs/*'
@@ -709,7 +709,7 @@ if [ "$db" != 'no' ] && [ ! -z "$DB_SYSTEM" ]; then
709709

710710
# Unzipping database dump
711711
if [ $backup_mode = 'zstd' ]; then
712-
zstd -d $tmpdir/db/$database/$database.*.sql.zst
712+
pzstd -d $tmpdir/db/$database/$database.*.sql.zst
713713
else
714714
gzip -d $tmpdir/db/$database/$database.*.sql.gz
715715
fi

install/hst-install-debian.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ fi
10761076

10771077
# Backups
10781078
echo "BACKUP_SYSTEM='local'" >> $HESTIA/conf/hestia.conf
1079-
echo "BACKUP_GZIP='9'" >> $HESTIA/conf/hestia.conf
1079+
echo "BACKUP_GZIP='4'" >> $HESTIA/conf/hestia.conf
10801080
echo "BACKUP_MODE='zstd'" >> $HESTIA/conf/hestia.conf
10811081

10821082
# Language

install/hst-install-ubuntu.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ fi
11261126

11271127
# Backups
11281128
echo "BACKUP_SYSTEM='local'" >> $HESTIA/conf/hestia.conf
1129-
echo "BACKUP_GZIP='9'" >> $HESTIA/conf/hestia.conf
1129+
echo "BACKUP_GZIP='4'" >> $HESTIA/conf/hestia.conf
11301130
echo "BACKUP_MODE='zstd'" >> $HESTIA/conf/hestia.conf
11311131

11321132
# Language

web/edit/server/index.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@
437437
// Change backup gzip level
438438
if (empty($_SESSION['error_msg'])) {
439439
if ($_POST['v_backup_gzip'] != $v_backup_gzip ) {
440+
if ( $_POST['v_backup_mode'] == 'gzip' ){
441+
$_POST['v_backup_gzip'] = 9;
442+
}
440443
exec (HESTIA_CMD."v-change-sys-config-value BACKUP_GZIP ".escapeshellarg($_POST['v_backup_gzip']), $output, $return_var);
441444
check_return_code($return_var,$output);
442445
unset($output);
@@ -445,14 +448,20 @@
445448
}
446449
}
447450

448-
// Change backup gzip level
451+
// Change backup mode
449452
if (empty($_SESSION['error_msg'])) {
450453
if ($_POST['v_backup_mode'] != $v_backup_mode ) {
451454
exec (HESTIA_CMD."v-change-sys-config-value BACKUP_MODE ".escapeshellarg($_POST['v_backup_mode']), $output, $return_var);
452455
check_return_code($return_var,$output);
453456
unset($output);
454457
if (empty($_SESSION['error_msg'])) $v_backup_mode = $_POST['v_backup_mode'];
455458
$v_backup_adv = 'yes';
459+
if ( $_POST['v_backup_mode'] == 'gzip' ){
460+
$_POST['v_backup_gzip'] = 9;
461+
if (empty($_SESSION['error_msg'])) $v_backup_gzip = $_POST['v_backup_gzip'];
462+
exec (HESTIA_CMD."v-change-sys-config-value BACKUP_GZIP ".escapeshellarg($_POST['v_backup_gzip']), $output, $return_var);
463+
}
464+
456465
}
457466
}
458467

web/templates/admin/edit_server.html

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,6 @@
602602
</table>
603603
</td>
604604
</tr>
605-
606-
607605
<tr>
608606
<td class="vst-text input-label step-top advanced-options">
609607
<a href="javascript:elementHideShow('backup');" class="vst-text">
@@ -630,7 +628,7 @@
630628
</tr>
631629
<tr>
632630
<td class="vst-text">
633-
<?php print _('Compression') ?>
631+
<?php print _('Compression') ?> <a href="https://docs.hestiacp.com/admin_docs/backups.html"><i class="fas fa-question-circle"></i></a>
634632
</td>
635633
</tr>
636634
<tr>
@@ -644,21 +642,18 @@
644642
</tr>
645643
<tr>
646644
<td class="vst-text">
647-
<?php print _('Compression level') ?>
645+
<?php print _('Compression level') ?> <a href="https://docs.hestiacp.com/admin_docs/backups.html"><i class="fas fa-question-circle"></i></a>
648646
</td>
649647
</tr>
650648
<tr>
651649
<td>
652650
<select class="vst-list" name="v_backup_gzip">
653-
<option value='1' <?php if($v_backup_gzip == '1') echo 'selected' ?>>1</option>
654-
<option value='2' <?php if($v_backup_gzip == '2') echo 'selected' ?>>2</option>
655-
<option value='3' <?php if($v_backup_gzip == '3') echo 'selected' ?>>3</option>
656-
<option value='4' <?php if($v_backup_gzip == '4') echo 'selected' ?>>4</option>
657-
<option value='5' <?php if($v_backup_gzip == '5') echo 'selected' ?>>5</option>
658-
<option value='6' <?php if($v_backup_gzip == '6') echo 'selected' ?>>6</option>
659-
<option value='7' <?php if($v_backup_gzip == '7') echo 'selected' ?>>7</option>
660-
<option value='8' <?php if($v_backup_gzip == '8') echo 'selected' ?>>8</option>
661-
<option value='9' <?php if($v_backup_gzip == '9') echo 'selected' ?>>9</option>
651+
<?php for($level = 1; $level < 20; $level++){
652+
?>
653+
<option value='<?=$level;?>' <?php if($v_backup_gzip == $level) echo 'selected' ?>><?=$level;?><?php if($level > 9){ echo sprintf(' (%s)', _('zstd only')); } ?></option>
654+
<?php
655+
}
656+
?>
662657
</select>
663658
<br><br>
664659
</td>
@@ -673,7 +668,8 @@
673668
<input type="text" size="20" class="vst-input" name="v_backup_dir" value="<?=trim($v_backup_dir, "'")?>">
674669
<br><br>
675670
</td>
676-
</tr> <tr>
671+
</tr>
672+
<tr>
677673
<td class="vst-text input-label">
678674
<label><input type="checkbox" size="20" class="vst-checkbox" name="v_backup_remote_adv" <?php if (!empty($v_backup_remote_adv)) echo "checked=yes" ?> onclick="javascript:elementHideShow('remote_backup');"> <?php print _('Remote backup');?></label>
679675
</td>
@@ -682,7 +678,7 @@
682678
<td class="vst-text input-label step-left">
683679
<table style="display:<?php if (empty($v_backup_remote_adv)) echo 'none';?> ;" id="remote_backup">
684680
<td class="vst-text">
685-
<?php print _('Protocol') ?>
681+
<?php print _('Protocol') ?> <a href="https://docs.hestiacp.com/admin_docs/backups.html"><i class="fas fa-question-circle"></i></a>
686682
</td>
687683
</tr>
688684
<tr>

0 commit comments

Comments
 (0)