def worker(self, args): is_initialized = Repo(Utils.get_backend(self.backup)).is_initialized() if self.edit: if not is_initialized: return False else: Repo(Utils.get_backend(self.backup)).init( self.backup.password.encode()) return True
def test_get_backend__azure(self): backup = Backup() backup.location = "Microsoft Azure" backup.azure_conn_str = environ["BLOBBACKUP_AZURE_CONN_STR"] backup.azure_container = environ["BLOBBACKUP_AZURE_CONTAINER"] backup.cloud_prefix = "tmp" self._verify_backend(Utils.get_backend(backup), AzureBackend)
def run(self): snapshot = Repo( Utils.get_backend(self.backup), thread_count=self.backup.thread_count, compression_level=self.backup.compression_level).get_snapshot_obj( self.backup.password.encode(), self.snapshot_id) self.downloaded.emit(snapshot)
def validate_backend(backup): try: if not Utils.get_backend(backup).check_connection(): return False, f"Cannot connect to {backup.location} backend" except Exception as e: exception_type = e.__class__.__name__ return False, f"Cannot connect to {backup.location} backend. Error: {exception_type}" return True, None
def test_get_backend__b2(self): backup = Backup() backup.location = "Backblaze B2" backup.b2_key_id = environ["BLOBBACKUP_B2_KEY_ID"] backup.b2_key = environ["BLOBBACKUP_B2_KEY"] backup.b2_bucket = environ["BLOBBACKUP_B2_BUCKET"] backup.cloud_prefix = "tmp" self._verify_backend(Utils.get_backend(backup), B2Backend)
def test_get_backend__gcp(self): backup = Backup() backup.location = "Google Cloud" backup.gcp_cred_file = environ["BLOBBACKUP_GCP_CRED_FILE"] backup.gcp_project = environ["BLOBBACKUP_GCP_PROJECT"] backup.gcp_bucket = environ["BLOBBACKUP_GCP_BUCKET"] backup.cloud_prefix = "tmp" self._verify_backend(Utils.get_backend(backup), GcpBackend)
def test_get_backend__aws(self): backup = Backup() backup.location = "Amazon AWS" backup.aws_key_id = environ["BLOBBACKUP_AWS_KEY_ID"] backup.aws_key = environ["BLOBBACKUP_AWS_KEY"] backup.aws_bucket = environ["BLOBBACKUP_AWS_BUCKET"] backup.cloud_prefix = "tmp" self._verify_backend(Utils.get_backend(backup), AwsBackend)
def populate_snapshots(self): self.snapshots_combo_box.clear() snapshot_ids = sorted(Repo(Utils.get_backend( self.backup)).get_snapshot_ids(), reverse=True) for snapshot_id in snapshot_ids: time_str = f"{pretty_time(snapshot_id)} ({snapshot_id})" self.snapshot_ids_to_str[time_str] = snapshot_id self.snapshots_combo_box.addItem(time_str) self.populate_snapshot() if self.snapshots_combo_box.count() is 0: QMessageBox.warning( self.window, "No Snapshots", "There are no snapshots available for viewing in this backup.")
def validate_repo(backup, just_save): backend = Utils.get_backend(backup) if not backend.check_connection(): return False, "Connection error" if just_save: repo = Repo(backend) if not repo.is_initialized(): return False, "This destination is not initialized" if not repo.check_password(backup.password.encode()): return False, "Password incorrect" else: repo = Repo(backend) if repo.is_initialized(): return False, "This destination is already initialized" return True, None
def __init__(self, backup, item, debug=False): QThread.__init__(self) self.backup = backup self.item = item try: self.repo = Repo( Utils.get_backend(backup), callback=lambda message: self.updated.emit(self.item, message), thread_count=backup.thread_count, compression_level=backup.compression_level, logger=setup_logger(self.backup.name, get_log_file_path(self.backup.name), logging.DEBUG if debug else logging.INFO)) except Exception as e: print(e) self.error.emit(e)
def __init__(self, backup, snapshot_id, restore_dir, paths, debug=False): QThread.__init__(self) self.backup = backup self.snapshot_id = snapshot_id self.restore_dir = restore_dir self.paths = paths try: self.repo = Repo(Utils.get_backend(backup), callback=self.updated.emit, thread_count=self.backup.thread_count, compression_level=self.backup.compression_level, logger=setup_logger( backup.name, get_log_file_path(backup.name), logging.DEBUG if debug else logging.INFO)) except Exception as e: self.error.emit(e)
def test_get_backend__local(self): backup = Backup() backup.location = "Local Directory" backup.local_directory = "." self._verify_backend(Utils.get_backend(backup), LocalBackend)
def test_get_backend__memory(self): backup = Backup() backup.location = "Memory" self._verify_backend(Utils.get_backend(backup), MemoryBackend)