How to use the persistence.update_restore function in Persistence

To help you get started, we’ve selected a few Persistence examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mongolab / mongodb-backup-system / mbs / strategy.py View on Github external
restore_options = self._apply_restore_options_overrides(restore_options)

        # execute dump command
        restore_info = self.backup_assistant.run_mongo_restore(
            restore, dest_uri, dump_dir, source_database_name,
            _restore_log_file_name(restore), _log_file_name(restore.source_backup),
            exclude_admin_system_users=exclude_admin_system_users,
            exclude_system_users=exclude_system_users,
            exclude_system_roles=exclude_system_roles,
            options=restore_options)

        if restore_info and "restoreCollectionCounts" in restore_info:
            restore.data_stats["restoreCollectionCounts"] = restore_info["restoreCollectionCounts"]

        update_restore(restore, properties="restoreCollectionCounts",
                       event_name="END_RESTORE_DUMP",
                       message="Restoring dump completed!")
github mongolab / mongodb-backup-system / mbs / strategy.py View on Github external
def _compute_restore_destination_stats(self, restore):
        logger.info("Computing destination stats for restore '%s'" %
                    restore.id)
        dest_connector = restore.destination.get_connector()
        dbname = restore.destination.database_name
        restore.destination_stats = dest_connector.get_stats(only_for_db=dbname)
        update_restore(restore, properties=["destinationStats"])
github mongolab / mongodb-backup-system / mbs / strategy.py View on Github external
def _upload_restore_log_file(self, restore):
        log_file_path = self._get_restore_log_path(restore)
        logger.info("Uploading log file for %s to target" % restore.id)

        update_restore(restore, event_name="START_UPLOAD_LOG_FILE",
                       message="Upload log file to target")
        log_dest_path = _upload_restore_log_file_dest(restore)
        log_ref = restore.source_backup.target.put_file(log_file_path,
                                          destination_path= log_dest_path,
                                          overwrite_existing=True)

        restore.log_target_reference = log_ref

        update_restore(restore, properties="logTargetReference",
                       event_name="END_UPLOAD_LOG_FILE",
                       message="Log file upload completed!")

        logger.info("Upload log file for %s completed successfully!" %
                    restore.id)
github mongolab / mongodb-backup-system / mbs / strategy.py View on Github external
def _extract_source_backup(self, restore):
        update_restore(restore, event_name="START_EXTRACT_BACKUP",
                       message="Extract backup file...")

        self.backup_assistant.extract_restore_source_backup(restore)

        update_restore(restore, event_name="END_EXTRACT_BACKUP",
                       message="Extract backup file completed!")
github mongolab / mongodb-backup-system / mbs / strategy.py View on Github external
def _download_source_backup(self, restore):
        update_restore(restore, event_name="START_DOWNLOAD_BACKUP",
                       message="Download source backup file...")

        self.backup_assistant.download_restore_source_backup(restore)

        update_restore(restore, event_name="END_DOWNLOAD_BACKUP",
                       message="Source backup file download complete!")
github mongolab / mongodb-backup-system / mbs / strategy.py View on Github external
def _validate_restore(self, restore):
        try:

            restore.data_stats["dumpCollectionCounts"] = read_dump_collection_counts(restore.source_backup)
            update_restore(restore, properties="dataStats",
                           event_name="READ_DUMP_COLLECTION_COUNTS",
                           message="Reading mongodump collection counts for validation")

            restore.data_stats["destinationCollectionCounts"] = self.get_destination_collection_counts(restore)
            update_restore(restore, properties="dataStats",
                           event_name="GET_DEST_COLLECTION_COUNTS",
                           message="Reading destination collection counts for validation")

            restore.valid = self._compare_all_collection_counts(restore)
            update_restore(restore, properties="valid",
                           event_name="SET_VALID",
                           message="setting valid to %s" % restore.valid)
        except Exception, ex:
            logger.exception("Error during validate restore '%s'" % restore.id)
github mongolab / mongodb-backup-system / mbs / strategy.py View on Github external
def _restore_dump(self, restore):

        file_reference = restore.source_backup.target_reference

        update_restore(restore, event_name="START_RESTORE_DUMP",
                       message="Running mongorestore...")

        # run mongoctl restore
        logger.info("Restoring using mongoctl restore")
        dump_dir = file_reference.file_name[: -4]



        # connect to the destination
        mongo_connector = self.get_restore_mongo_connector(restore)
        dest_uri = mongo_connector.restore_uri()

        dest_uri_wrapper = mongo_uri_tools.parse_mongo_uri(dest_uri)

        source_stats = restore.source_backup.source_stats
        source_mongo_version = source_stats and "version" in source_stats and \
github mongolab / mongodb-backup-system / mbs / strategy.py View on Github external
def cleanup_restore(self, restore):

        logger.info("Running Cleanup for restore %s" % restore.id)
        update_restore(restore, event_name="CLEANUP",
                       message="Running cleanup")

        self.backup_assistant.delete_task_workspace(restore)