Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
241 changes: 241 additions & 0 deletions src/vorta/assets/UI/export_tar_dialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExportTarDialog</class>
<widget class="QDialog" name="ExportTarDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>450</height>
</rect>
</property>
<property name="windowTitle">
<string>Export to Tarball</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_info">
<property name="text">
<string>Export the selected archive to a tarball.</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_archive">
<property name="text">
<string>Archive:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="archiveNameLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>archive_name</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_dest">
<property name="text">
<string>Destination:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_dest">
<item>
<widget class="QLineEdit" name="destinationInput">
<property name="placeholderText">
<string>Path to save the .tar file</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnBrowse">
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_compress">
<property name="text">
<string>Compression:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboCompression">
<item>
<property name="text">
<string>none</string>
</property>
</item>
<item>
<property name="text">
<string>gzip</string>
</property>
</item>
<item>
<property name="text">
<string>lz4</string>
</property>
</item>
<item>
<property name="text">
<string>zstd</string>
</property>
</item>
<item>
<property name="text">
<string>xz</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_strip">
<property name="text">
<string>Strip Components:</string>
</property>
<property name="toolTip">
<string>Remove the specified number of leading path elements.</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="spinStripComponents">
<property name="minimum">
<number>0</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_excludes">
<property name="text">
<string>Exclude Patterns:</string>
</property>
<property name="toolTip">
<string>Space-separated list of exclude patterns.</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="inputExcludes">
<property name="placeholderText">
<string>e.g. *.tmp home/user/.cache</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_paths">
<property name="text">
<string>Specific Paths:</string>
</property>
<property name="toolTip">
<string>Space-separated list of paths to extract.</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="inputPaths">
<property name="placeholderText">
<string>Leave empty to export all</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_format">
<property name="text">
<string>Tar Format:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="comboFormat">
<item>
<property name="text">
<string>GNU</string>
</property>
</item>
<item>
<property name="text">
<string>PAX</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ExportTarDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ExportTarDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
71 changes: 71 additions & 0 deletions src/vorta/borg/export_tar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from vorta.utils import borg_compat

from .borg_job import BorgJob


class BorgExportTar(BorgJob):
"""
Job to export an archive to a tarball.
"""

def started_event(self):
self.app.backup_started_event.emit()
self.app.backup_progress_event.emit(
f"[{self.params['profile_name']}] {self.tr('Exporting archive to tarball…')}"
)

def finished_event(self, result):
self.app.backup_finished_event.emit(result)
self.result.emit(result)
self.app.backup_progress_event.emit(f"[{self.params['profile_name']}] {self.tr('Export to tarball finished.')}")

@classmethod
def prepare(
cls,
profile,
archive_name,
destination_file,
compression=None,
strip_components=0,
paths=None,
excludes=None,
tar_format=None,
):
ret = super().prepare(profile)
if not ret['ok']:
return ret
else:
# Set back to false, so we can do our own checks here.
ret['ok'] = False

cmd = ['borg', 'export-tar']

if compression and compression != 'none':
cmd.append(f'--tar-filter={compression}')

if strip_components > 0:
cmd.append(f'--strip-components={strip_components}')

if excludes:
for pattern in excludes:
cmd.extend(['-e', pattern])

if tar_format and borg_compat.check('V2') and tar_format != 'GNU':
cmd.append(f'--tar-format={tar_format}')

if borg_compat.check('V2'):
cmd += ['-r', profile.repo.url, archive_name]
else:
cmd.append(f'{profile.repo.url}::{archive_name}')

cmd.append(destination_file)

if paths:
cmd.extend(paths)

ret['ok'] = True
ret['cmd'] = cmd
return ret
ret['cmd'] = cmd

return ret
21 changes: 21 additions & 0 deletions src/vorta/views/archive_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ def archiveitem_contextmenu(self, pos: QPoint):
action = menu.addAction(button.icon(), button.text(), connection)
action.setEnabled(button.isEnabled())

# Export to Tar
if len(selected_rows) == 1:
menu.addAction(get_colored_icon('file'), self.tr("Export to Tarball"), self.export_tar_action)

menu.popup(self.archiveTable.viewport().mapToGlobal(pos))

def cancel_action(self):
Expand Down Expand Up @@ -819,6 +823,23 @@ def extract_archive_result(self, result):
"""Finished extraction."""
self._toggle_all_buttons(True)

def export_tar_action(self):
"""
Open a dialog to export the selected archive to a tarball.
"""
row_selected = self.archiveTable.selectionModel().selectedRows()
if len(row_selected) != 1:
return

archive_cell = self.archiveTable.item(row_selected[0].row(), 4)
if archive_cell:
archive_name = archive_cell.text()

from vorta.views.export_tar_dialog import ExportTarDialog

dialog = ExportTarDialog(self, self.profile(), archive_name)
dialog.exec()

def cell_double_clicked(self, row=None, column=None):
if not self.bRename.isEnabled():
return
Expand Down
Loading
Loading