예제 #1
0
파일: driver.py 프로젝트: quaddra/engage
 def upgrade(self, package, old_metadata, backup_root_directory):
     """For the upgrade of a django sqlite database, we restore the previous version
     and let the django app resource manager handle the schema upgrade (if needed).
     """
     backup_file = self._find_backup_archive(backup_root_directory, old_metadata.id)
     logger.info("Upgrading %s by restoring file at %s" % (self.id, backup_file))
     backup.restore(backup_file, move=False)
예제 #2
0
파일: backup.py 프로젝트: quaddra/engage
def restore_engage_files(backup_directory, move=False):
    backup_archive = os.path.join(backup_directory, "engage_files.tar")
    if not os.path.exists(backup_archive):
        compressed_backup_archive = os.path.join(backup_directory, "engage_files.tar.gz")
        if not os.path.exists(compressed_backup_archive):
            raise UserError(errors[ENGAGE_BACKUP_NOT_FOUND],
                            msg_args={"file":backup_archive,"compressed_file":compressed_backup_archive})
        backup_archive = compressed_backup_archive
    backup.restore(backup_archive, move)
예제 #3
0
 def restore(self, backup_to_directory, package):
     backup_location = self._find_backup_archive(backup_to_directory)
     try:
         logger.debug("Restoring resource %s from %s" % (self.id, backup_location))
         if os.geteuid() != 0 and backup.check_if_restore_requires_superuser(backup_location):
             logger.info("Running restore via sudo for resource %s" % self.id)
             backup.restore_as_sudo_subprocess(backup_location, self._get_sudo_password(), move=False)
         else:
             backup.restore(backup_location, move=False)
     except:
         exc_info = (exc_tp, exc_v, ecx_tb) = sys.exc_info()
         raise convert_exc_to_user_error(
             exc_info,
             errors[EXC_IN_RESTORE_CALL],
             msg_args={"id": self.id, "file": backup_location, "exc_typ": exc_tp.__name__, "exc_val": exc_v},
         )