From 16021372dff59b1e514837279dc385398ae476ef Mon Sep 17 00:00:00 2001 From: Iker Saiz Date: Sat, 21 Nov 2026 22:18:22 +0100 Subject: [PATCH 1/2] Add backup format to the GUI --- usr/lib/linuxmint/mintbackup/mintbackup.py | 11 ++++- usr/share/linuxmint/mintbackup/mintbackup.ui | 44 +++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/usr/lib/linuxmint/mintbackup/mintbackup.py b/usr/lib/linuxmint/mintbackup/mintbackup.py index 7f24666..a1a3412 100755 --- a/usr/lib/linuxmint/mintbackup/mintbackup.py +++ b/usr/lib/linuxmint/mintbackup/mintbackup.py @@ -205,6 +205,11 @@ def __init__(self): self.builder.get_object("filechooserbutton_backup_dest").set_current_folder(BACKUP_DIR) self.builder.get_object("filechooserbutton_package_source").set_current_folder(BACKUP_DIR) + widget = self.builder.get_object("backup_format") + widget.connect("changed", self.on_backup_format_changed) + backup_format = self.settings.get_string("backup-format") + widget.set_active_id(backup_format) + # Menubar accel_group = Gtk.AccelGroup() self.main_window.add_accel_group(accel_group) @@ -223,6 +228,10 @@ def __init__(self): menu.append(item) menu.show_all() + def on_backup_format_changed(self, widget): + backup_format = widget.get_active_id() + self.settings.set_string("backup-format", backup_format) + def on_treeview_excludes_selection_changed(self, selection): liststore, treeiter = selection.get_selected() self.builder.get_object("button_remove_exclude").set_sensitive((treeiter and liststore.get_value(treeiter, 2) != BACKUP_DIR)) @@ -274,7 +283,7 @@ def add_all_hidden_to_treeview(self, widget, treeview): for item in new_items: model.append(item) - + def remove_all_from_treeview(self, button, treeview): model = treeview.get_model() model.clear() diff --git a/usr/share/linuxmint/mintbackup/mintbackup.ui b/usr/share/linuxmint/mintbackup/mintbackup.ui index b7a82ce..05c5d55 100644 --- a/usr/share/linuxmint/mintbackup/mintbackup.ui +++ b/usr/share/linuxmint/mintbackup/mintbackup.ui @@ -1,5 +1,5 @@ - + @@ -304,6 +304,48 @@ + + False + True + 0 + + + + + True + False + 12 + + + True + False + Please choose backup format: + 0.05000000074505806 + + + False + True + 0 + + + + + True + False + + tar + tar.gz + tar.bz2 + tar.xz + + + + False + True + 1 + + + False True From d42c18ee1f3f374506d464d2e9152a026ccfa2fd Mon Sep 17 00:00:00 2001 From: Iker Saiz Date: Sat, 21 Nov 2026 23:48:19 +0100 Subject: [PATCH 2/2] Set compression level --- usr/lib/linuxmint/mintbackup/mintbackup.py | 35 ++++++++++++++-------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/usr/lib/linuxmint/mintbackup/mintbackup.py b/usr/lib/linuxmint/mintbackup/mintbackup.py index a1a3412..144172e 100755 --- a/usr/lib/linuxmint/mintbackup/mintbackup.py +++ b/usr/lib/linuxmint/mintbackup/mintbackup.py @@ -1,4 +1,5 @@ #!/usr/bin/python3 +from bz2 import compress import gettext import hashlib import locale @@ -539,18 +540,26 @@ def backup(self): self.operating = True backup_format = self.settings.get_string("backup-format") - if backup_format == "tar": - backup_mode = "w" - elif backup_format == "tar.gz": - backup_mode = "w:gz" - elif backup_format == "tar.bz2": - backup_mode = "w:bz2" - elif backup_format == "tar.xz": - backup_mode = "w:xz" - else: - print("Invalid format %s. Please choose between tar, tar.gz, tar.bz2 or tar.xz." % backup_format) - self.operating = False - sys.exit(1) + match backup_format: + case "tar": + backup_mode = "w" + backup_kwargs = {} + case "tar.gz": + backup_mode = "w:gz" + # defalt compress level of gzip command + backup_kwargs = {"compresslevel": 6} + case "tar.bz2": + backup_mode = "w:bz2" + # defalt compress level of bzip2 command + backup_kwargs = {"compresslevel": 9} + case "tar.xz": + backup_mode = "w:xz" + # default compress level of xz command + backup_kwargs = {"preset": 6} + case backup_format: + print("Invalid format %s. Please choose between tar, tar.gz, tar.bz2 or tar.xz." % backup_format) + self.operating = False + sys.exit(1) GLib.idle_add(self.set_widgets_before_backup) @@ -576,7 +585,7 @@ def backup(self): self.filename = os.path.join(self.backup_dest, "%s.%s" % (timestamp, backup_format)) try: - self.tar_archive = tarfile.open(name=self.temp_filename, dereference=self.follow_links, mode=backup_mode, bufsize=1024) + self.tar_archive = tarfile.open(name=self.temp_filename, dereference=self.follow_links, mode=backup_mode, bufsize=1024, **backup_kwargs) mintfile = os.path.join(self.backup_dest, META_FILE) self.tar_archive.add(mintfile, arcname=META_FILE, recursive=False) except Exception as detail: