Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if wifi_is_disallowed.count() > 0 and profile.repo.is_remote_repo():
ret['message'] = trans_late('messages', 'Current Wifi is not allowed.')
return ret
ret['profile'] = profile
ret['repo'] = profile.repo
# Run user-supplied pre-backup command
if cls.pre_post_backup_cmd(ret) != 0:
ret['message'] = trans_late('messages', 'Pre-backup command returned non-zero exit code.')
return ret
if not profile.repo.is_remote_repo() and not os.path.exists(profile.repo.url):
ret['message'] = trans_late('messages', 'Repo folder not mounted or moved.')
return ret
if 'zstd' in profile.compression and not borg_compat.check('ZSTD'):
ret['message'] = trans_late('messages', 'Your current Borg version does not support ZStd compression.')
return ret
cmd = ['borg', 'create', '--list', '--info', '--log-json', '--json', '--filter=AM', '-C', profile.compression]
# Add excludes
# Partly inspired by borgmatic/borgmatic/borg/create.py
if profile.exclude_patterns is not None:
exclude_dirs = []
for p in profile.exclude_patterns.split('\n'):
if p.strip():
expanded_directory = os.path.expanduser(p.strip())
exclude_dirs.append(expanded_directory)
if exclude_dirs:
pattern_file = tempfile.NamedTemporaryFile('w', delete=False)
def toggle_available_compression(self):
use_zstd = borg_compat.check('ZSTD')
for algo in ['zstd,3', 'zstd,8']:
ix = self.repoCompression.findData(algo)
self.repoCompression.model().item(ix).setEnabled(use_zstd)
def init_encryption(self):
encryption_algos = [
['Repokey-Blake2 (Recommended, key stored in repository)', 'repokey-blake2'],
['Repokey', 'repokey'],
['Keyfile-Blake2 (Key stored in home directory)', 'keyfile-blake2'],
['Keyfile', 'keyfile'],
['None (not recommended)', 'none']
]
for desc, name in encryption_algos:
self.encryptionComboBox.addItem(self.tr(desc), name)
if not borg_compat.check('BLAKE2'):
self.encryptionComboBox.model().item(0).setEnabled(False)
self.encryptionComboBox.model().item(2).setEnabled(False)
self.encryptionComboBox.setCurrentIndex(1)
ret = {'ok': False}
# Do checks to see if running Borg is possible.
if cls.is_running():
ret['message'] = trans_late('messages', 'Backup is already in progress.')
return ret
if cls.prepare_bin() is None:
ret['message'] = trans_late('messages', 'Borg binary was not found.')
return ret
if profile.repo is None:
ret['message'] = trans_late('messages', 'Add a backup repository first.')
return ret
if not borg_compat.check('JSON_LOG'):
ret['message'] = trans_late('messages', 'Your Borg version is too old. >=1.1.0 is required.')
return ret
# Try to get password from chosen keyring backend.
logger.debug("Using %s keyring to store passwords.", keyring.__class__.__name__)
ret['password'] = keyring.get_password('vorta-repo', profile.repo.url)
# Try to fall back to DB Keyring, if we use the system keychain.
if ret['password'] is None and keyring.is_primary:
logger.debug('Password not found in primary keyring. Falling back to VortaDBKeyring.')
ret['password'] = VortaDBKeyring().get_password('vorta-repo', profile.repo.url)
# Give warning and continue if password is found there.
if ret['password'] is not None:
logger.warning('Found password in database, but secure storage was available. '
'Consider re-adding the repo to use it.')
self.setupUi(self)
self.setWindowTitle('Vorta for Borg Backup')
self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
self.app = parent
self.current_profile = BackupProfileModel.select().order_by('id').first()
self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.WindowMinimizeButtonHint)
self.tests_running = False
# Load tab models
self.repoTab = RepoTab(self.repoTabSlot)
self.sourceTab = SourceTab(self.sourceTabSlot)
self.archiveTab = ArchiveTab(self.archiveTabSlot)
self.scheduleTab = ScheduleTab(self.scheduleTabSlot)
self.miscTab = MiscTab(self.miscTabSlot)
self.miscTab.set_borg_details(borg_compat.version, borg_compat.path)
self.tabWidget.setCurrentIndex(0)
self.repoTab.repo_changed.connect(self.archiveTab.populate_from_profile)
self.repoTab.repo_added.connect(self.archiveTab.list_action)
self.tabWidget.currentChanged.connect(self.scheduleTab._draw_next_scheduled_backup)
self.createStartBtn.clicked.connect(self.app.create_backup_action)
self.cancelButton.clicked.connect(self.app.backup_cancelled_event.emit)
QShortcut(QKeySequence("Ctrl+W"), self).activated.connect(self.on_close_window)
QShortcut(QKeySequence("Ctrl+Q"), self).activated.connect(self.on_close_window)
self.app.backup_started_event.connect(self.backup_started_event)
self.app.backup_finished_event.connect(self.backup_finished_event)
self.app.backup_log_event.connect(self.set_status)
self.app.backup_cancelled_event.connect(self.backup_cancelled_event)