def backup(self): # Do a system backup before update sickrage.app.log.info("Config backup in progress...") sickrage.app.alerts.message(_('Updater'), _('Config backup in progress...')) try: backupDir = os.path.join(sickrage.app.data_dir, 'backup') if not os.path.isdir(backupDir): os.mkdir(backupDir) if backup_app_data(backupDir, keep_latest=True): sickrage.app.log.info("Config backup successful, updating...") sickrage.app.alerts.message( _('Updater'), _('Config backup successful, updating...')) return True else: sickrage.app.log.warning( "Config backup failed, aborting update") sickrage.app.alerts.error( _('Updater'), _('Config backup failed, aborting update')) return False except Exception as e: sickrage.app.log.warning( f'Update: Config backup failed. Error: {e!r}') sickrage.app.alerts.error( _('Updater'), _('Config backup failed, aborting update')) return False
def handle_get(self): backup_dir = self.get_argument('backupDir') final_result = '' if backup_dir: if backup_app_data(backup_dir): final_result += _("Backup SUCCESSFUL") else: final_result += _("Backup FAILED!") else: final_result += _("You need to choose a folder to save your backup to first!") final_result += "<br>\n" return self.write(final_result)