def _run_pre_backup(self): """Create archival contents in dump dir""" try: est_dump_size = self.estimate_dump_size() avail = operating_system.get_bytes_free_on_fs(DB2_DBPATH) if est_dump_size > avail: self.cleanup() raise OSError( _("Need more free space to backup db2 database," " estimated %(est_dump_size)s" " and found %(avail)s bytes free ") % { 'est_dump_size': est_dump_size, 'avail': avail }) operating_system.create_directory(DB2_BACKUP_DIR, system.DB2_INSTANCE_OWNER, system.DB2_INSTANCE_OWNER, as_root=True) service.run_command(system.QUIESCE_DB2) dbNames = self.list_dbnames() for dbName in dbNames: service.run_command(system.BACKUP_DB % { 'dbname': dbName, 'dir': DB2_BACKUP_DIR }) service.run_command(system.UNQUIESCE_DB2) except exception.ProcessExecutionError as e: LOG.debug("Caught exception when preparing the directory") self.cleanup() raise e
def _run_pre_backup(self): """Create archival contents in dump dir""" try: est_dump_size = self.estimate_dump_size() avail = operating_system.get_bytes_free_on_fs(MONGODB_DBPATH) if est_dump_size > avail: self.cleanup() # TODO(atomic77) Though we can fully recover from this error # BackupRunner will leave the trove instance in a BACKUP state raise OSError( _("Need more free space to run mongodump, " "estimated %(est_dump_size)s" " and found %(avail)s bytes free ") % { 'est_dump_size': est_dump_size, 'avail': avail }) operating_system.create_directory(MONGO_DUMP_DIR, as_root=True) operating_system.chown(MONGO_DUMP_DIR, mongo_system.MONGO_USER, mongo_system.MONGO_USER, as_root=True) # high timeout here since mongodump can take a long time utils.execute_with_timeout('mongodump', '--out', MONGO_DUMP_DIR, *(self.app.admin_cmd_auth_params()), run_as_root=True, root_helper='sudo', timeout=LARGE_TIMEOUT) except exception.ProcessExecutionError as e: LOG.debug("Caught exception when creating the dump") self.cleanup() raise e
def _run_pre_backup(self): """Create archival contents in dump dir""" try: est_dump_size = self.estimate_dump_size() avail = operating_system.get_bytes_free_on_fs(MONGODB_DBPATH) if est_dump_size > avail: self.cleanup() # TODO(atomic77) Though we can fully recover from this error # BackupRunner will leave the trove instance in a BACKUP state raise OSError(_("Need more free space to run mongodump, " "estimated %(est_dump_size)s" " and found %(avail)s bytes free ") % {'est_dump_size': est_dump_size, 'avail': avail}) operating_system.create_directory(MONGO_DUMP_DIR, as_root=True) operating_system.chown(MONGO_DUMP_DIR, mongo_system.MONGO_USER, mongo_system.MONGO_USER, as_root=True) # high timeout here since mongodump can take a long time utils.execute_with_timeout( 'mongodump', '--out', MONGO_DUMP_DIR, *(self.app.admin_cmd_auth_params()), run_as_root=True, root_helper='sudo', timeout=LARGE_TIMEOUT ) except exception.ProcessExecutionError as e: LOG.debug("Caught exception when creating the dump") self.cleanup() raise e
def _run_pre_backup(self): """Create archival contents in dump dir""" try: est_dump_size = self.estimate_dump_size() avail = operating_system.get_bytes_free_on_fs(DB2_DBPATH) if est_dump_size > avail: self.cleanup() raise OSError(_("Need more free space to backup db2 database," " estimated %(est_dump_size)s" " and found %(avail)s bytes free ") % {'est_dump_size': est_dump_size, 'avail': avail}) operating_system.create_directory(DB2_BACKUP_DIR, system.DB2_INSTANCE_OWNER, system.DB2_INSTANCE_OWNER, as_root=True) service.run_command(system.QUIESCE_DB2) dbNames = self.list_dbnames() for dbName in dbNames: service.run_command(system.BACKUP_DB % { 'dbname': dbName, 'dir': DB2_BACKUP_DIR}) service.run_command(system.UNQUIESCE_DB2) except exception.ProcessExecutionError as e: LOG.debug("Caught exception when preparing the directory") self.cleanup() raise e
def _run_pre_backup(self): """Create backupset in backup dir""" self.cleanup() operating_system.create_directory(BACKUP_DIR, user='******', group='oinstall', force=True, as_root=True) try: est_backup_size = self.estimate_backup_size() avail = operating_system.get_bytes_free_on_fs( CONF.get('oracle').mount_point) if est_backup_size > avail: # TODO(schang): BackupRunner will leave the trove instance # in a BACKUP state raise OSError( _("Need more free space to run RMAN backup, " "estimated %(est_backup_size)s" " and found %(avail)s bytes free ") % { 'est_backup_size': est_backup_size, 'avail': avail }) backup_dir = (BACKUP_DIR + '/%s') % self.db_name operating_system.create_directory(backup_dir, user='******', group='oinstall', force=True, as_root=True) backup_cmd = ("""\"\ rman target %(admin_user)s/%(admin_pswd)s@localhost/%(db_name)s <<EOF run { configure backup optimization on; backup incremental level=%(backup_level)s as compressed backupset database format '%(backup_dir)s/%%I_%%u_%%s_%(backup_id)s.dat' plus archivelog; backup current controlfile format '%(backup_dir)s/%%I_%%u_%%s_%(backup_id)s.ctl'; } EXIT; EOF\" """ % { 'admin_user': ADMIN_USER, 'admin_pswd': self.oracnf.admin_password, 'db_name': self.db_name, 'backup_dir': backup_dir, 'backup_id': self.backup_id, 'backup_level': self.backup_level }) utils.execute_with_timeout("su - oracle -c " + backup_cmd, run_as_root=True, root_helper='sudo', timeout=LARGE_TIMEOUT, shell=True, log_output_on_error=True) except exception.ProcessExecutionError as e: LOG.debug("Caught exception when creating backup files") self.cleanup() raise e
def _run_pre_backup(self): """Create backupset in backup dir""" self.cleanup() operating_system.create_directory(BACKUP_DIR, user='******', group='oinstall', force=True, as_root=True) try: est_backup_size = self.estimate_backup_size() avail = operating_system.get_bytes_free_on_fs(CONF.get('oracle'). mount_point) if est_backup_size > avail: # TODO(schang): BackupRunner will leave the trove instance # in a BACKUP state raise OSError(_("Need more free space to run RMAN backup, " "estimated %(est_backup_size)s" " and found %(avail)s bytes free ") % {'est_backup_size': est_backup_size, 'avail': avail}) backup_dir = (BACKUP_DIR + '/%s') % self.db_name operating_system.create_directory(backup_dir, user='******', group='oinstall', force=True, as_root=True) backup_cmd = ("""\"\ rman target %(admin_user)s/%(admin_pswd)s@localhost/%(db_name)s <<EOF run { configure backup optimization on; backup incremental level=%(backup_level)s as compressed backupset database format '%(backup_dir)s/%%I_%%u_%%s_%(backup_id)s.dat' plus archivelog; backup current controlfile format '%(backup_dir)s/%%I_%%u_%%s_%(backup_id)s.ctl'; } EXIT; EOF\" """ % {'admin_user': ADMIN_USER, 'admin_pswd': self.oracnf.admin_password, 'db_name': self.db_name, 'backup_dir': backup_dir, 'backup_id': self.backup_id, 'backup_level': self.backup_level}) utils.execute_with_timeout("su - oracle -c " + backup_cmd, run_as_root=True, root_helper='sudo', timeout=LARGE_TIMEOUT, shell=True, log_output_on_error=True) except exception.ProcessExecutionError as e: LOG.debug("Caught exception when creating backup files") self.cleanup() raise e
def _run_pre_backup(self): """ Before performing the actual backup we need to make sure that there is enough space to store the backups. The backup size is the sum of the size of the databases and if it is an online backup, the size of the archived logs is also factored in. """ backup_size_bytes = self.estimate_backup_size() log_size_bytes = self.estimate_log_size() total_backup_size_gb = utils.to_gb(backup_size_bytes + log_size_bytes) free_bytes = operating_system.get_bytes_free_on_fs(system.MOUNT_POINT) free_gb = utils.to_gb(free_bytes) if total_backup_size_gb > free_gb: raise exception.InsufficientSpaceForBackup % { 'backup_size': total_backup_size_gb, 'free': free_gb } self.run_backup()
def _run_pre_backup(self): """Create backupset in backup dir""" self.cleanup() try: est_backup_size = self.estimate_backup_size() avail = operating_system.get_bytes_free_on_fs( self.app.paths.data_dir) if est_backup_size > avail: # TODO(schang): BackupRunner will leave the trove instance # in a BACKUP state raise OSError( _("Need more free space to run RMAN backup, " "estimated %(est_backup_size)s " "and found %(avail)s bytes free.") % { 'est_backup_size': est_backup_size, 'avail': avail }) bkp_dir = self.app.paths.db_backup_dir operating_system.create_directory( bkp_dir, user=self.app.instance_owner, group=self.app.instance_owner_group, force=True, as_root=True) cmds = [ "configure backup optimization on", ("backup incremental level=%s as compressed backupset " "database format '%s/%%I_%%u_%%s_%s.dat' plus archivelog" % (self.backup_level, bkp_dir, self.backup_id)), ("backup current controlfile format '%s/%%I_%%u_%%s_%s.ctl'" % (bkp_dir, self.backup_id)) ] script = self.app.rman_scripter( commands=cmds, sid=self.db_name, t_user=self.app.admin_user_name, t_pswd=self.app.admin.ora_config.admin_password) script.run(timeout=CONF.restore_usage_timeout) except exception.ProcessExecutionError as e: LOG.debug("Caught exception when creating backup files") self.cleanup() raise e
def _run_pre_backup(self): """ Before performing the actual backup we need to make sure that there is enough space to store the backups. The backup size is the sum of the size of the databases and if it is an online backup, the size of the archived logs is also factored in. """ backup_size_bytes = self.estimate_backup_size() log_size_bytes = self.estimate_log_size() total_backup_size_gb = utils.to_gb(backup_size_bytes + log_size_bytes) free_bytes = operating_system.get_bytes_free_on_fs(system.MOUNT_POINT) free_gb = utils.to_gb(free_bytes) if total_backup_size_gb > free_gb: raise exception.InsufficientSpaceForBackup % { 'backup_size': total_backup_size_gb, 'free': free_gb } self.run_backup()
def _run_pre_backup(self): """Create backupset in backup dir""" self.cleanup() try: est_backup_size = self.estimate_backup_size() avail = operating_system.get_bytes_free_on_fs(self.app.paths.data_dir) if est_backup_size > avail: # TODO(schang): BackupRunner will leave the trove instance # in a BACKUP state raise OSError( _( "Need more free space to run RMAN backup, " "estimated %(est_backup_size)s " "and found %(avail)s bytes free." ) % {"est_backup_size": est_backup_size, "avail": avail} ) bkp_dir = self.app.paths.db_backup_dir operating_system.create_directory( bkp_dir, user=self.app.instance_owner, group=self.app.instance_owner_group, force=True, as_root=True ) cmds = [ "configure backup optimization on", ( "backup incremental level=%s as compressed backupset " "database format '%s/%%I_%%u_%%s_%s.dat' plus archivelog" % (self.backup_level, bkp_dir, self.backup_id) ), ("backup current controlfile format '%s/%%I_%%u_%%s_%s.ctl'" % (bkp_dir, self.backup_id)), ] script = self.app.rman_scripter( commands=cmds, sid=self.db_name, t_user=self.app.admin_user_name, t_pswd=self.app.admin.ora_config.admin_password, ) script.run(timeout=CONF.restore_usage_timeout) except exception.ProcessExecutionError as e: LOG.debug("Caught exception when creating backup files") self.cleanup() raise e