Add auto/live export modes, add ZST compression.

This update adds auto and live export modes, also adds support for the fast lossless ZSTD compression algorithm.
This commit is contained in:
JRGTH
2025-12-25 02:39:22 -04:00
parent 759d1d061d
commit 2610a95a70
5 changed files with 98 additions and 62 deletions
+1
View File
@@ -3,6 +3,7 @@
====================== ======================
Version Description Version Description
1.2.30......Add auto and live export modes, add ZST compression support.
1.2.29......Fix jail backup. 1.2.29......Fix jail backup.
1.2.28......Minor cosmetic/wording changes. 1.2.28......Minor cosmetic/wording changes.
1.2.27......Minor cosmetic/wording changes. 1.2.27......Minor cosmetic/wording changes.
Executable → Regular
+62 -50
View File
@@ -145,58 +145,62 @@ error_notify()
runtime_config() runtime_config()
{ {
# Run-time configuration and checks. # Run-time configuration and checks.
if [ -f "${INSTALLPATH}/${BASTILLECONF}" ]; then if [ -d "${INSTALLPATH}" ]; then
if ! sysrc -f ${BASTILLECONF} -qc bastille_prefix="${CWDIR}"; then
sysrc -f ${INSTALLPATH}/${BASTILLECONF} bastille_prefix="${CWDIR}" >/dev/null 2>&1
fi
fi
# Check for required directories and files. if [ -f "${INSTALLPATH}/${BASTILLECONF}" ]; then
if [ ! -d "${CWDIR}/backups" ]; then if ! sysrc -f ${BASTILLECONF} -qc bastille_prefix="${CWDIR}"; then
mkdir -p ${CWDIR}/backups sysrc -f ${INSTALLPATH}/${BASTILLECONF} bastille_prefix="${CWDIR}" >/dev/null 2>&1
fi
if [ ! -d "${CWDIR}/conf" ]; then
mkdir -p ${CWDIR}/conf
fi
if [ ! -d "${CWDIR}/log" ]; then
mkdir -p ${CWDIR}/log
fi
if [ ! -d "${CWDIR}/locale-bastille" ]; then
mkdir -p ${CWDIR}/locale-bastille
fi
if [ ! -d "${CWDIR}/freebsd-update" ]; then
mkdir ${CWDIR}/freebsd-update
fi
if [ ! -f "${CWDIR}${BASTILLECONFFILE}" ]; then
touch ${CWDIR}${BASTILLECONFFILE}
fi
if [ ! -d "${CWDIR}/system" ]; then
mkdir -p ${CWDIR}/system
fi
# Check for permissions.
if [ -f "${FREEBSD_UPDATE}/freebsd-update" ]; then
FREEBSD_UPDATE_PERMS=$(stat -f "%Op" ${FREEBSD_UPDATE}/freebsd-update)
if [ "${FREEBSD_UPDATE_PERMS}" != 100555 ]; then
chmod 0555 ${FREEBSD_UPDATE}/freebsd-update
fi
fi
# Workaround to check for host /tmp sane permissions.
# This is because after working with Linux jails, this may be changed to 0777 but XigmaNAS wants 1777.
if grep -qw '\"chmod\ 777\ /tmp\"' ${INSTALLPATH}/usr/local/share/bastille/create.sh; then
sed -i '' 's|\"chmod\ 777\ /tmp\"|\"chmod\ 1777\ /tmp\"|g' ${INSTALLPATH}/usr/local/share/bastille/create.sh
else
if [ -d "/tmp" ]; then
TMP_PERMS=$(stat -f "%Op" "/tmp")
if [ "${TMP_PERMS}" != "41777" ]; then
chmod 1777 /tmp
fi fi
fi fi
fi
# Check and append new config parameters. # Check for required directories and files.
update_config if [ ! -d "${CWDIR}/backups" ]; then
mkdir -p ${CWDIR}/backups
fi
if [ ! -d "${CWDIR}/conf" ]; then
mkdir -p ${CWDIR}/conf
fi
if [ ! -d "${CWDIR}/log" ]; then
mkdir -p ${CWDIR}/log
fi
if [ ! -d "${CWDIR}/locale-bastille" ]; then
mkdir -p ${CWDIR}/locale-bastille
fi
if [ ! -d "${CWDIR}/freebsd-update" ]; then
mkdir ${CWDIR}/freebsd-update
fi
if [ ! -f "${CWDIR}${BASTILLECONFFILE}" ]; then
touch ${CWDIR}${BASTILLECONFFILE}
fi
if [ ! -d "${CWDIR}/system" ]; then
mkdir -p ${CWDIR}/system
fi
# Check for permissions.
if [ -f "${FREEBSD_UPDATE}/freebsd-update" ]; then
FREEBSD_UPDATE_PERMS=$(stat -f "%Op" ${FREEBSD_UPDATE}/freebsd-update)
if [ "${FREEBSD_UPDATE_PERMS}" != 100555 ]; then
chmod 0555 ${FREEBSD_UPDATE}/freebsd-update
fi
fi
# Workaround to check for host /tmp sane permissions.
# This is because after working with Linux jails, this may be changed to 0777 but XigmaNAS wants 1777.
if grep -qw '\"chmod\ 777\ /tmp\"' ${INSTALLPATH}/usr/local/share/bastille/create.sh; then
sed -i '' 's|\"chmod\ 777\ /tmp\"|\"chmod\ 1777\ /tmp\"|g' ${INSTALLPATH}/usr/local/share/bastille/create.sh
else
if [ -d "/tmp" ]; then
TMP_PERMS=$(stat -f "%Op" "/tmp")
if [ "${TMP_PERMS}" != "41777" ]; then
chmod 1777 /tmp
fi
fi
fi
# Check and append new config parameters.
update_config
fi
} }
bastille_initial_download() bastille_initial_download()
@@ -469,7 +473,7 @@ include_files()
sysrc -f ${CWDIR}${EXTCONF} VNET_ENABLE="YES" >/dev/null 2>&1 sysrc -f ${CWDIR}${EXTCONF} VNET_ENABLE="YES" >/dev/null 2>&1
# Include missing system files. # Include missing system files.
# Symlink the files in embedded platforms. # Symlink the files in embedded platforms.
USRBIN_FILES="ar diff3 makewhatis setfib sum" USRBIN_FILES="ar diff3 makewhatis setfib sum zstd"
USRSBIN_FILES="etcupdate" USRSBIN_FILES="etcupdate"
LOCALBIN_FILES="jib" LOCALBIN_FILES="jib"
if [ "${PRDPLATFORM}" = "x64-embedded" ]; then if [ "${PRDPLATFORM}" = "x64-embedded" ]; then
@@ -1042,7 +1046,7 @@ zfs_activate()
else else
error_notify "Invalid ZFS configuration." error_notify "Invalid ZFS configuration."
fi fi
sysrc -f ${CWDIR}${EXTCONF} ZFS_ACTIVATED="YES" >/dev/null 2>&1 zfs_support_enabled
exit 0 exit 0
} }
@@ -1504,6 +1508,14 @@ update_config()
sysrc -f ${INSTALLPATH}/${BASTILLECONF} bastille_template_vlan="default/vlan" sysrc -f ${INSTALLPATH}/${BASTILLECONF} bastille_template_vlan="default/vlan"
fi fi
# Compress/Decompress parameters.
if ! grep -qw 'bastille_compress_zst_options=' ${INSTALLPATH}/${BASTILLECONF}; then
sysrc -f ${INSTALLPATH}/${BASTILLECONF} bastille_compress_zst_options="-3 -v"
fi
if ! grep -qw 'bastille_decompress_zst_options=' ${INSTALLPATH}/${BASTILLECONF}; then
sysrc -f ${INSTALLPATH}/${BASTILLECONF} bastille_decompress_zst_options="-k -d -c -v"
fi
# Remove deprecated parameters based on minimum version. # Remove deprecated parameters based on minimum version.
if grep -qw 'bastille_jail_interface' ${INSTALLPATH}/${BASTILLECONF}; then if grep -qw 'bastille_jail_interface' ${INSTALLPATH}/${BASTILLECONF}; then
sysrc -f ${INSTALLPATH}/${BASTILLECONF} -x bastille_jail_interface sysrc -f ${INSTALLPATH}/${BASTILLECONF} -x bastille_jail_interface
Binary file not shown.
+34 -11
View File
@@ -122,7 +122,8 @@ if($_POST):
$bastille_version_min = "0920210714"; $bastille_version_min = "0920210714";
$bastille_version_format = str_replace(".", "", $bastille_version); $bastille_version_format = str_replace(".", "", $bastille_version);
$export_option = ""; $export_option = "";
$skip_safemode = ""; #$skip_safemode = "";
$skip_livemode = "";
if(isset($_POST['format'])): if(isset($_POST['format'])):
$export_format = $_POST['format']; $export_format = $_POST['format'];
@@ -138,21 +139,35 @@ if($_POST):
break; break;
case 'tgz': case 'tgz':
$user_export_format = "--tgz"; $user_export_format = "--tgz";
$skip_safemode = "yes"; #$skip_safemode = "yes";
$skip_livemode = "yes";
break; break;
case 'txz': case 'txz':
$user_export_format = "--txz"; $user_export_format = "--txz";
$skip_safemode = "yes"; #$skip_safemode = "yes";
$skip_livemode = "yes";
break;
case 'tzst':
$user_export_format = "--tzst";
#$skip_safemode = "yes";
$skip_livemode = "yes";
break; break;
case 'xz': case 'xz':
$user_export_format = "--xz"; $user_export_format = "--xz";
break; break;
case 'zst':
$user_export_format = "--zst";
break;
endswitch; endswitch;
if($pconfig['safemode']):
$export_option = "--auto";
endif;
if ($zfs_activated == "YES"): if ($zfs_activated == "YES"):
if($pconfig['safemode']): if($pconfig['livemode']):
if(!$skip_safemode): if(!$export_option):
$export_option = "--auto"; $export_option = "--live";
endif; endif;
endif; endif;
endif; endif;
@@ -167,9 +182,9 @@ if($_POST):
else: else:
if ($pconfig['format'] == "default"): if ($pconfig['format'] == "default"):
$export_format = "--txz"; $export_format = "--txz";
$cmd = ("/usr/local/bin/bastille export $export_format '{$item}'"); $cmd = ("/usr/local/bin/bastille export $export_option $export_format '{$item}'");
else: else:
$cmd = ("/usr/local/bin/bastille export $user_export_format '{$item}'"); $cmd = ("/usr/local/bin/bastille export $export_option $user_export_format '{$item}'");
endif; endif;
endif; endif;
@@ -492,6 +507,7 @@ function action_change() {
showElementById('backup_tr', 'hide'); showElementById('backup_tr', 'hide');
showElementById('format_tr', 'hide'); showElementById('format_tr', 'hide');
showElementById('safemode_tr', 'hide'); showElementById('safemode_tr', 'hide');
showElementById('livemode_tr', 'hide');
showElementById('prioritynumber_tr','hide'); showElementById('prioritynumber_tr','hide');
var action = document.iform.action.value; var action = document.iform.action.value;
switch (action) { switch (action) {
@@ -499,6 +515,7 @@ function action_change() {
showElementById('backup_tr', 'show'); showElementById('backup_tr', 'show');
showElementById('format_tr', 'show'); showElementById('format_tr', 'show');
showElementById('safemode_tr', 'show'); showElementById('safemode_tr', 'show');
showElementById('livemode_tr', 'show');
break; break;
case "clone": case "clone":
showElementById('newname_tr','show'); showElementById('newname_tr','show');
@@ -625,20 +642,26 @@ $document->render();
'raw' => gettext('RAW'), 'raw' => gettext('RAW'),
'tgz' => gettext('TGZ'), 'tgz' => gettext('TGZ'),
'txz' => gettext('TXZ'), 'txz' => gettext('TXZ'),
'tzst' => gettext('TZST'),
'xz' => gettext('XZ'), 'xz' => gettext('XZ'),
'zst' => gettext('ZST'),
]; ];
else: else:
$c_action = [ $c_action = [
'default' => gettext('Default'), 'default' => gettext('Default'),
'tgz' => gettext('TGZ'), 'tgz' => gettext('TGZ'),
'txz' => gettext('TXZ'), 'txz' => gettext('TXZ'),
'tzst' => gettext('TZST'),
]; ];
endif; endif;
html_combobox2('action',gettext('Action'),!empty($pconfig['action']),$a_action,'',true,false,'action_change()'); html_combobox2('action',gettext('Action'),!empty($pconfig['action']),$a_action,'',true,false,'action_change()');
html_combobox2('format',gettext('Archive format'),!empty($pconfig['format']),$c_action,'',true,false); html_combobox2('format',gettext('Archive format'),!empty($pconfig['format']),$c_action,'',true,false);
if ($zfs_activated == "YES"): if ($zfs_activated == "YES"):
html_checkbox2('safemode',gettext('Safe ZFS export'),!empty($pconfig['safemode']) ? true : false,gettext('Safely stop and start a ZFS jail before the exporting process, this has no effect on .TGZ/TXZ since the jail should be stopped regardless.'),'',false); html_checkbox2('safemode',gettext('Safe Jail export'),!empty($pconfig['safemode']) ? true : false,gettext('Safely stop and start the jail before the exporting process.'),'',false);
html_checkbox2('livemode',gettext('Live ZFS export'),!empty($pconfig['livemode']) ? true : false,gettext('Export a running ZFS jail, safe export overrides this option, this has no effect on .TGZ/TXZ/TZST since the jail should be stopped regardless.'),'',false);
else:
html_checkbox2('safemode',gettext('Safe Jail export'),!empty($pconfig['safemode']) ? true : false,gettext('Safely stop and start the jail before the exporting process.'),'',false);
endif; endif;
html_inputbox2('confirmname',gettext('Enter name for confirmation'),!empty($pconfig['confirmname']),'',true,30); html_inputbox2('confirmname',gettext('Enter name for confirmation'),!empty($pconfig['confirmname']),'',true,30);
html_inputbox2('prioritynumber',gettext('Enter priority value'),!empty($pconfig['prioritynumber']),'',true,30); html_inputbox2('prioritynumber',gettext('Enter priority value'),!empty($pconfig['prioritynumber']),'',true,30);
@@ -649,7 +672,7 @@ $document->render();
html_filechooser("source_path",gtext("Source Data Directory"),!empty($pconfig['source_path']), gtext("Source data directory to be shared, full path here, if the path contain spaces they will be automatically escaped with the ASCII \"\\040\" octal code."), !empty($source_path), false, 60); html_filechooser("source_path",gtext("Source Data Directory"),!empty($pconfig['source_path']), gtext("Source data directory to be shared, full path here, if the path contain spaces they will be automatically escaped with the ASCII \"\\040\" octal code."), !empty($source_path), false, 60);
html_filechooser("target_path",gtext("Target Data Directory"),!empty($pconfig['target_path']), gtext("Target data directory to be mapped, full path to jail here, if the path contain spaces they will be automatically escaped with the ASCII \"\\040\" octal code."), !empty($target_path), false, 60); html_filechooser("target_path",gtext("Target Data Directory"),!empty($pconfig['target_path']), gtext("Target data directory to be mapped, full path to jail here, if the path contain spaces they will be automatically escaped with the ASCII \"\\040\" octal code."), !empty($target_path), false, 60);
html_checkbox2("path_check", gettext("Source/Target path check"),!empty($pconfig['path_check']) ? true : false, gettext("If this option is selected no examination of the source/target directory paths will be performed."), "<b><font color='red'>".gettext("Please use this option only if you know what you are doing here!")."</font></b>", false); html_checkbox2("path_check", gettext("Source/Target path check"),!empty($pconfig['path_check']) ? true : false, gettext("If this option is selected no examination of the source/target directory paths will be performed."), "<b><font color='red'>".gettext("Please use this option only if you know what you are doing here!")."</font></b>", false);
html_checkbox2('advanced',gettext('Advanced jail configuration Files'),!empty($pconfig['advanced']) ? true : false,gettext('I want to edit the jail files manually, Warning: It is recommended to stop the jail before config edit to prevent issues.'),'',true); html_checkbox2('advanced',gettext('Advanced jail configuration Files'),!empty($pconfig['advanced']) ? true : false,gettext('I want to edit the jail files manually, Warning: It is recommended to stop the jail before editing the config to prevent issues.'),'',true);
html_checkbox2('readonly',gettext('Read-Only Mode'),!empty($pconfig['readonly']) ? true : false,gettext('Set target directory in Read-Only mode.'),'',true); html_checkbox2('readonly',gettext('Read-Only Mode'),!empty($pconfig['readonly']) ? true : false,gettext('Set target directory in Read-Only mode.'),'',true);
html_checkbox2('automount',gettext('Auto-mount Nullfs'),!empty($pconfig['automount']) ? true : false,gettext('Auto-mount the nullfs mountpoint if the container is already running.'),'',true); html_checkbox2('automount',gettext('Auto-mount Nullfs'),!empty($pconfig['automount']) ? true : false,gettext('Auto-mount the nullfs mountpoint if the container is already running.'),'',true);
html_checkbox2('createdir',gettext('Create Target Directory'),!empty($pconfig['createdir']) ? true : true,gettext('Create target directory if missing (recommended).'),'',true); html_checkbox2('createdir',gettext('Create Target Directory'),!empty($pconfig['createdir']) ? true : true,gettext('Create target directory if missing (recommended).'),'',true);
@@ -664,7 +687,7 @@ $document->render();
html_text2('jail_release',gettext('Current base release:'),htmlspecialchars($current_release)); html_text2('jail_release',gettext('Current base release:'),htmlspecialchars($current_release));
html_text2('auto_boot',gettext('Enable container auto-startup'),htmlspecialchars("This will cause the container to automatically start each time the system restart.")); html_text2('auto_boot',gettext('Enable container auto-startup'),htmlspecialchars("This will cause the container to automatically start each time the system restart."));
html_text2('no_autoboot',gettext('Disable container auto-startup'),htmlspecialchars("This will disable the container automatic startup.")); html_text2('no_autoboot',gettext('Disable container auto-startup'),htmlspecialchars("This will disable the container automatic startup."));
html_text2('backup',gettext('Export container'),htmlspecialchars("This will export a container to a compressed file/image, please execute `bastille export` for more info in regards exporting formats, Default is .XZ on ZFS setups or .TXZ otherwise, For faster compressed backups consider .GZ/.TGZ.")); html_text2('backup',gettext('Export container'),htmlspecialchars("This will export a container to a compressed file/image, please execute `bastille export` for more info in regards exporting formats, Default is .XZ on ZFS setups or .TXZ otherwise, For faster compressed backups consider .ZST/.TZST or .GZ/.TGZ"));
if ($disable_base_change == "no"): if ($disable_base_change == "no"):
html_combobox2('release',gettext('New base release'),!empty($pconfig['release']),$b_action,gettext("Warning: This will change current shared base to the selected base on the thin container only, the user is responsible for package updates and/or general incompatibilities issues, or use the command line for native upgrade."),true,false,); html_combobox2('release',gettext('New base release'),!empty($pconfig['release']),$b_action,gettext("Warning: This will change current shared base to the selected base on the thin container only, the user is responsible for package updates and/or general incompatibilities issues, or use the command line for native upgrade."),true,false,);
+1 -1
View File
@@ -1 +1 @@
1.2.29 1.2.30