Esempio n. 1
0
    def mount_backup(self):
        """Mount the selected archive in the tmp directory. If it succeeds the
        mount_path gets written to a property of the main_window."""
        try:
            archive_name = self.selected_archive
        except AttributeError:
            error = BorgException("Please create or select an archive first.")
            archive_name = None
            show_error(error)

        # only continue if the user selected an archive
        if archive_name:
            mount_path = os.path.join('/tmp/', archive_name)
            create_path(mount_path)
            # only continue if the mount_path is writeable
            if os.access(mount_path, os.W_OK):
                thread = borg.MountThread(archive_name, mount_path)
                try:
                    thread.run()
                    self.mount_paths.append(mount_path)
                    open_path(mount_path)
                except BorgException as e:
                    show_error(e)
                    remove_path(mount_path)
            else:
                # Opens the path in a file manager
                open_path(mount_path)
Esempio n. 2
0
 def update_ui(self):
     """Updates the archive list and repository stats in the UI."""
     try:
         self._update_archives()
         self._update_repository_stats()
     except BorgException as e:
         show_error(e)
Esempio n. 3
0
    def restore_backup(self):
        """Restores a selected backup to the given path."""
        try:
            archive_name = self.selected_archive
            target_path = self._get_target_path()
        except AttributeError:
            error = BorgException("Please create or select an archive first.")
            archive_name = None
            target_path = None
            show_error(error)

        # Only restore the backup if the target is writeable and the archive
        # was selected.
        if check_path(target_path) and archive_name:
            try:
                restore_path = os.path.join(target_path, archive_name)
                create_path(restore_path)
                thread = borg.RestoreThread(archive_name, restore_path)
                dialog = ProgressDialog(thread)
                dialog.label_info.setText(
                    "Borg-Qt is currently restoring a backup.")
                dialog.exec_()
                open_path(restore_path)
            except BorgException as e:
                show_error(e)
                remove_path(restore_path)
Esempio n. 4
0
 def run(self):
     self.json_output, self.json_err = self.p.communicate()
     self.p.wait()
     try:
         self.process_json_error(self.json_err)
     except BorgException as e:
         show_error(e)
         self.stop()
Esempio n. 5
0
 def start(self):
     """This method is intendet to be used only once at the application
     start. It reads the configuration file and sets the required
     environment variables."""
     try:
         self.config.read()
         # show the help window if needed and save it's answer
         if not self.config.hide_help:
             self.config.config['borgqt']['hide_help'] = (str(
                 self.show_help()))
             self.config.write()
         self.config._set_environment_variables()
         self._update_archives()
         self._update_repository_stats()
     except BorgException as e:
         show_error(e)
         sys.exit(1)
Esempio n. 6
0
 def create_backup(self):
     """Creates a backup of the selected item in the treeview."""
     if not self._check_mounts():
         return
     try:
         self._check_path()
         backup_thread = borg.BackupThread([self.src_path],
                                           excludes=self.config.excludes,
                                           prefix=self.config.prefix)
         backup_dialog = ProgressDialog(backup_thread)
         backup_dialog.label_info.setText("Borg-Qt is currently creating an"
                                          " archive.")
         backup_dialog.exec_()
         if self.config.retention_policy_enabled:
             prune_thread = borg.PruneThread(self.config.retention_policy)
             prune_dialog = ProgressDialog(prune_thread)
             prune_dialog.label_info.setText("Borg-Qt is currently pruning "
                                             "the repository.")
             prune_dialog.exec_()
         self.update_ui()
     except BorgException as e:
         show_error(e)
Esempio n. 7
0
    def delete_backup(self):
        """Deletes the selected archive from the repository."""
        if not self._check_mounts():
            return
        try:
            archive_name = self.selected_archive
        except AttributeError:
            error = BorgException("Please create or select an archive first.")
            archive_name = None
            show_error(error)

        # Only continue if an archive was selected.
        if archive_name:
            # Prompt the user before continuing.
            if self.yes_no("Do you want to delete this archive?"):
                try:
                    thread = borg.DeleteThread(archive_name)
                    dialog = ProgressDialog(thread)
                    dialog.label_info.setText(
                        "Borg-Qt is currently deleting an archive.")
                    dialog.exec_()
                    self.update_ui()
                except BorgException as e:
                    show_error(e)