def check_innodb(pathinfo, ensure_subdir_of_datadir=False): """Check that all tablespaces are in the datadir and filesystem""" is_unsafe_for_lvm = False is_unsafe_for_physical_backups = False datadir = realpath(pathinfo.datadir) datadir_mp = getmount(datadir) for tablespace in pathinfo.walk_innodb_shared_tablespaces(): space_mp = getmount(tablespace) if space_mp != datadir_mp: LOG.error( "InnoDB shared tablespace %s is not on the same " "filesystem as the datadir %s", tablespace, datadir, ) is_unsafe_for_lvm = True if ensure_subdir_of_datadir and not is_subdir(tablespace, datadir): LOG.error( "InnoDB shared tablespace %s is not within a " "subdirectory of the datadir %s.", tablespace, datadir, ) is_unsafe_for_physical_backups = True ib_logdir = pathinfo.get_innodb_logdir() ib_logdir_mp = getmount(ib_logdir) if ib_logdir_mp != datadir_mp: LOG.error( "innodb-log-group-home-dir %s is not on the same filesystem " "as the MySQL datadir %s", ib_logdir, datadir, ) is_unsafe_for_lvm = True if ensure_subdir_of_datadir and not is_subdir(ib_logdir, datadir): LOG.error( "innodb-log-group-home-dir %s is not a subdirectory of " "the datadir %s.", ib_logdir, datadir, ) is_unsafe_for_physical_backups = True if is_unsafe_for_lvm: raise BackupError( "One or more InnoDB file paths are not on the same " "logical volume as the datadir. This is unsafe for " "LVM snapshot backups." ) if is_unsafe_for_physical_backups: raise BackupError( "One or more InnoDB files are not contained within " "the MySQL datadir. A consistent filesystem backup " "is not supported with this configuration in the " "current plugin version." )
def check_innodb(pathinfo, ensure_subdir_of_datadir=False): """Check that all tablespaces are in the datadir and filesystem""" is_unsafe_for_lvm = False is_unsafe_for_physical_backups = False datadir = realpath(pathinfo.datadir) datadir_mp = getmount(datadir) for tablespace in pathinfo.walk_innodb_shared_tablespaces(): space_mp = getmount(tablespace) if space_mp != datadir_mp: LOG.error( "InnoDB shared tablespace %s is not on the same " "filesystem as the datadir %s", tablespace, datadir, ) is_unsafe_for_lvm = True if ensure_subdir_of_datadir and not is_subdir(tablespace, datadir): LOG.error( "InnoDB shared tablespace %s is not within a " "subdirectory of the datadir %s.", tablespace, datadir, ) is_unsafe_for_physical_backups = True ib_logdir = pathinfo.get_innodb_logdir() ib_logdir_mp = getmount(ib_logdir) if ib_logdir_mp != datadir_mp: LOG.error( "innodb-log-group-home-dir %s is not on the same filesystem " "as the MySQL datadir %s", ib_logdir, datadir, ) is_unsafe_for_lvm = True if ensure_subdir_of_datadir and not is_subdir(ib_logdir, datadir): LOG.error( "innodb-log-group-home-dir %s is not a subdirectory of " "the datadir %s.", ib_logdir, datadir, ) is_unsafe_for_physical_backups = True if is_unsafe_for_lvm: raise BackupError("One or more InnoDB file paths are not on the same " "logical volume as the datadir. This is unsafe for " "LVM snapshot backups.") if is_unsafe_for_physical_backups: raise BackupError("One or more InnoDB files are not contained within " "the MySQL datadir. A consistent filesystem backup " "is not supported with this configuration in the " "current plugin version.")
def remap_path(path, mountpoint): """Remap a path to a new mountpoint >>> remap_path('/mnt/raid10/foo/bar/baz', '/mnt/snapshot') '/mnt/snapshot/foo/bar/baz' """ rpath = relpath(path, getmount(path)) return os.path.join(mountpoint, rpath)
def remap_path(path, mountpoint): """Remap a path to a new mountpoint >>> remap_path('/mnt/raid10/foo/bar/baz', '/mnt/snapshot') '/mnt/snapshot/foo/bar/baz' """ rpath = relpath(path, getmount(path)) return os.path.join(mountpoint, rpath)
def report_low_space(event, entry): total_space = disk_capacity(entry.path) free_space = disk_free(entry.path) if free_space < 0.10 * total_space: LOG.warning("Extremely low free space on %s's filesystem (%s).", entry.path, getmount(entry.path)) LOG.warning("%s of %s [%.2f%%] remaining", format_bytes(free_space), format_bytes(total_space), (float(free_space) / total_space) * 100)
def report_low_space(event, entry): total_space = disk_capacity(entry.path) free_space = disk_free(entry.path) if free_space < 0.10 * total_space: LOG.warning("Extremely low free space on %s's filesystem (%s).", entry.path, getmount(entry.path)) LOG.warning( "%s of %s [%.2f%%] remaining", format_bytes(free_space), format_bytes(total_space), (float(free_space) / total_space) * 100, )