def wiz_execute(wiz): log.debug("Executing backup creation wizard") config = Config.get_config() name = wiz.fields["name"].value path = wiz.fields["folderpath"].value excl = [] for typ in config.file_types.iterkeys(): if wiz.fields['excl-'+typ].value: excl.append(typ) store = wiz.fields["store"].value b = Backup(name) b.active = True b.include_folders = [path] b.include_packages = True b.exclude_types = excl b.store = store b.excrypt = False b.sched_type = "daily/weekly" b.sched_times = "19:00/Sun" b.verify = False b.notify_msg = True b.notify_email = False b.shutdown_after = False config.backups[name] = b config.save() update_crontab(config.backups) dlg.Info(wiz, _("Your backup has been successfully created.")) app.broadcast_update()
def onSave(self, event): try: self.save() self.state = ViewState self.update_state() self.lstItems.SetStringSelection(self.txtName.GetValue()) # Inform all other panels about the data change. app.broadcast_update() except Exception as e: dlg.Warn(self, str(e))
def wiz_execute(wiz): db = DB() config = Config.get_config() backups = config.backups.keys() backups.sort() for name in backups: if wiz.fields[name].value: # Get the backup object and store backup = config.backups[name] store = config.storage[backup.store].copy() # For each run on the store with ProgressDialog(wiz, _("Connecting"), _("Connecting to the store.\nPlease wait...")): store.connect() prog_dlg = ProgressDialog(wiz, _("Loading"), _("Retrieving data from store.\nPlease wait...")) prog_dlg.Show() try: try: runs = store.list(backup.name) except: # If it fails, there were no backup runs runs = [] runs.sort() for run in runs: (date, type) = run.split(" ") date = datetime.strptime(date, const.DateTimeFormat) db.start_run(backup.name, store.name, type, date) db.save_message(_("Database rebuild started")) try: store_size, _file_sizes, nfiles, nfolders = recover_run(config, db, backup, store, run) db.save_message(_("Database rebuild complete")) db.update_run_stats(store_size, nfiles, nfolders, backup.include_packages, "") db.update_run_status(const.StatusSuccess) except Exception as e: msg = _("Database rebuild failed. {error}").format(error=str(e)) db.save_message(msg) db.update_run_status(const.StatusFailed) dlg.Warn(wiz, msg, _("Error")) return finally: prog_dlg.Destroy() store.disconnect() wiz.parent.force_rebuild() # Now tell app about change. app.broadcast_update() dlg.Info(wiz, _("Your backup files database has been rebuilt.\nYou can now view your file and backup history."), _("Rebuild"))
def wiz_execute(wiz): # Connect if wiz.fields["storagetype"].value == _("Local Folder"): name = wiz.fields["name"].value path = wiz.fields["folderpath"].value store = FolderStore(name, 0, False, path) elif wiz.fields["storagetype"].value == _("FTP Server"): name = wiz.fields["name"].value server = wiz.fields["ftpserver"].value login = wiz.fields["ftplogin"].value password = wiz.fields["ftppassword"].value root = wiz.fields["ftproot"].value sftp = wiz.fields["sftp"].value store = FTPStore(name, 0, False, server, root, login, password, sftp) log.debug("Store = ", store) elif wiz.fields["storagetype"].value == _("DropBox"): name = wiz.fields["name"].value login = wiz.fields["dblogin"].value password = wiz.fields["dbpassword"].value root = wiz.fields["dbroot"].value key = wiz.fields["dbkey"].value secret_key = wiz.fields["dbsecretkey"].value store = DropBoxStore(name, 0, False, root, login, password, key, secret_key) elif wiz.fields["storagetype"].value == _("Amazon S3"): name = wiz.fields["name"].value key = wiz.fields["s3key"].value secret_key = wiz.fields["s3secretkey"].value bucket = wiz.fields["s3bucket"].value store = S3Store(name, 0, False, bucket, key, secret_key) elif wiz.fields["storagetype"].value == _("Server Share"): name = wiz.fields["name"].value path = wiz.fields["sharepath"].value mountcmd = wiz.fields["sharemountcmd"].value umountcmd = wiz.fields["shareumountcmd"].value store = ShareStore(name, 0, False, path, mountcmd, umountcmd) try: with ProgressDialog(wiz, _("Creating Store"), _("Creating and testing new store.\nPlease wait...")): # we will rely on the user to test the store # store.test() config = Config.get_config() config.storage[store.name] = store config.save() dlg.Info(wiz, _("Store successfully created.")) app.broadcast_update() except Exception as e: dlg.Warn(wiz, str(e), _("Failed to create store"))
def delete(self, name): use = self.db.store_usage(name) if use.size > 0: log.debug(name, utils.readable_form(use.size)) msg = _("Store '{store}' contains {size} of backups.\nAre you sure?").format( store=name, size=utils.readable_form(use.size)) mbox = OptionDialog(self, msg, _("Delete Store"), _("Also delete all backup data stored on the store.")) if mbox.ShowModal() == wx.ID_OK: with ProgressDialog(self, _("Deleting"), _("Deleting store %s.\nPlease wait. This can take a while..." % name)): self.delete_store(name, mbox.chkOption.GetValue()) self.clear() self.state = ViewState else: ret = dlg.OkCancel(self, _("Store '{store}' is not currently used. Delete?").format(store=name)) if ret == wx.ID_OK: with ProgressDialog(self, _("Deleting"), _("Deleting store %s.\nPlease wait. This can take a while..." % name)): self.delete_store(name, False) self.clear() self.state = ViewState app.broadcast_update()
def delete(self, name): # Lets get some statistics runs = self.db.runs(backupname=name) num_runs = len(runs) size = 0 for run in runs: size += run.size if num_runs > 0: msg = _("Backup '{backup}' has {numruns} runs stored, " \ "totalling {size} of remote data.\n" \ "Are you sure you want to delete the backup definition?\n" \ "(hint - its usually better to just deactivate the backup)").format(\ backup=name, numruns=num_runs, size=utils.readable_form(size)) mbox = OptionDialog(self, msg, _("Delete Backup Definition"), _("Also delete all backup data stored remotely\nNote that this cannot be undone.")) if mbox.ShowModal() != wx.ID_OK: return delete_offsite_data = mbox.chkOption.GetValue() else: msg = _("Backup '{backup}' has never run. Are you " \ "sure you want to delete the backup definition?").format(backup=name) if dlg.OkCancel(self, msg, _("Confirm Delete")) != wx.ID_OK: return delete_offsite_data = False with ProgressDialog(self, _("Deleting"), _("Deleting backup %s%s.\nPlease wait...") % (name, " and all offsite data" if delete_offsite_data else "")): self.delete_backup(name, delete_offsite_data) import time time.sleep(3) self.clear() self.state = ViewState app.broadcast_update()