Example #1
0
    def delete_backup(self):
        current_item = self.backups_tree_widget.currentItem()
        if current_item is None:
            return
        backup_name = current_item.whatsThis(0)
        backup = Backups.load(backup_name)

        password, ret = QInputDialog.getText(self, "Password",
                                             "Enter your password:"******"Incorrect password",
                                "Incorrect password")
            return

        reply = QMessageBox.question(
            self, "Confirm delete?",
            f"Are you sure you want to delete {backup_name}?",
            QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
        if reply is QMessageBox.Yes:
            Backups.delete(backup_name)
            self.populate()
            self.app.scheduler.reload()
Example #2
0
    def update_logs(self, force=False):
        current_item = self.backups_tree_widget.currentItem()
        if current_item is None:
            return
        backup_name = current_item.whatsThis(0)
        backup = Backups.load(backup_name)

        if not force and (self.log_file_thread.backup is not None
                          and backup_name == self.log_file_thread.backup.name):
            return

        self.log_text_edit.clear()
        self.old_logs_thread = OldLogsThread(backup_name)
        self.old_logs_thread.started.connect(
            lambda: self.log_text_edit.setPlainText("Loading logs..."))
        self.old_logs_thread.result.connect(
            lambda x: self.got_old_logs(x, backup))
        self.old_logs_thread.start()

        self.log_file_thread.set_backup(backup)

        self.set_sensitive_actions_status(False)
        self.backups_tree_widget.setEnabled(False)
        self.log_text_edit.hide()
        self.go_action.setEnabled(False)
        self.stop_action.setEnabled(False)
        self.only_errors_radio_button.setEnabled(False)
        self.show_everything_radio_button.setEnabled(False)
Example #3
0
    def go_backup(self, status=False, backup_name=None):
        if self.thread is not None:
            self.app.notify(
                f"Scheduled backup {backup_name} skipped because a restore is running."
            )
            return
        if backup_name is None:
            current_item = self.backups_tree_widget.currentItem()
            if current_item is None:
                return
            backup_name = current_item.whatsThis(0)
        else:
            current_item = self.get_item_with_name(backup_name)
        backup = Backups.load(backup_name)

        if backup_name in self.threads:
            self.app.notify(
                f"Scheduled backup {backup_name} skipped because it's already running."
            )
            return

        self.app.notify(f"{backup_name} backup started")

        if backup.paths is None or len(backup.paths) is 0:
            QMessageBox.warning(self, "Error",
                                "This backup has no folders selected")
            return

        current_item.setText(2, "Running")
        self.status_bar.clearMessage()

        thread = BackupThread(backup, current_item,
                              self.debug_mode_action.isChecked())

        self.threads[backup_name] = thread
        thread.updated.connect(lambda item, message: item.setText(2, message))
        thread.backup_finished.connect(self.backup_finished)
        thread.stop_initiated.connect(
            lambda item: item.setText(2, "Stopping backup"))
        thread.stop_finished.connect(self.backup_stopped)
        thread.error.connect(self.thread_error)
        thread.files_skipped.connect(self.files_skipped)
        thread.start()

        self.update_logs(force=True)

        self.set_sensitive_actions_status(False)
        self.go_action.setEnabled(False)
Example #4
0
    def edit_backup(self):
        current_item = self.backups_tree_widget.currentItem()
        if current_item is None:
            return
        backup_name = current_item.whatsThis(0)

        if backup_name in self.threads:
            return

        backup = Backups.load(backup_name)

        password, ret = QInputDialog.getText(self, "Password",
                                             "Enter your password:"******"Incorrect password",
                                "Incorrect password")
            return

        self.backup_settings(BackupSettings(backup, self, True))
Example #5
0
    def view_backup(self):
        current_item = self.backups_tree_widget.currentItem()
        if current_item is None:
            return
        backup_name = current_item.whatsThis(0)
        backup = Backups.load(backup_name)

        password, ret = QInputDialog.getText(self, "Password",
                                             "Enter your password:"******"Incorrect password",
                                "Incorrect password")
            return

        dialog = RestoreDialog(self, backup)
        dialog.setParent(self, Qt.Dialog)
        if dialog.exec_():
            self.thread = RestoreThread(backup, dialog.snapshot_id,
                                        dialog.restore_dir, dialog.paths,
                                        self.debug_mode_action.isChecked())
            self.thread.updated.connect(
                lambda x: self.status_bar.showMessage(x))
            self.thread.restore_finished.connect(self.restore_finished)
            self.thread.error.connect(self.restore_thread_error)
            self.set_sensitive_actions_status(False)
            self.set_control_actions_status(False)
            if backup.name in self.threads and self.threads[
                    backup.name] is not None:
                self.app.notify(
                    f"Restore skipped because this backup is running.")
                return
            self.thread.start()
            self.app.notify("Restore started")

            self.update_logs(force=True)