Permalink
Browse files

update dry-run for mysqldump-lvm plugin

  • Loading branch information...
1 parent 2f84238 commit 112796daa97acda9c62babe40fe154349969901f @abg abg committed Jan 11, 2013
Showing with 34 additions and 11 deletions.
  1. +34 −11 plugins/holland.backup.mysql_lvm/holland/backup/mysql_lvm/plugin/mysqldump/plugin.py
@@ -6,6 +6,7 @@
from holland.lib.lvm import LogicalVolume, CallbackFailuresError, \
LVMCommandError, relpath, getmount
from holland.lib.mysql.client import MySQLError
+from holland.core.util.fmt import format_bytes
from holland.core.util.path import directory_size
from holland.core.exceptions import BackupError
from holland.backup.mysql_lvm.plugin.common import build_snapshot, \
@@ -87,16 +88,14 @@ def backup(self):
raise BackupError("Failed to lookup logical volume for %s: %s" %
(datadir, str(exc)))
- if self.dry_run:
- _dry_run(volume)
- # do the normal mysqldump dry-run
- return self.mysqldump_plugin.backup()
# create a snapshot manager
- snapshot = build_snapshot(self.config['mysql-lvm'], volume)
+ snapshot = build_snapshot(self.config['mysql-lvm'], volume,
+ suppress_tmpdir=self.dry_run)
# calculate where the datadirectory on the snapshot will be located
rpath = relpath(datadir, getmount(datadir))
- snap_datadir = os.path.abspath(os.path.join(snapshot.mountpoint, rpath))
+ snap_datadir = os.path.abspath(os.path.join(snapshot.mountpoint or
+ '/tmp', rpath))
# setup actions to perform at each step of the snapshot process
setup_actions(snapshot=snapshot,
config=self.config,
@@ -105,6 +104,18 @@ def backup(self):
spooldir=self.target_directory,
plugin=self.mysqldump_plugin)
+ if self.config['mysqldump']['bin-log-position']:
+ LOG.warn("bin-log-position is not supported with mysqldump-lvm.")
+ LOG.warn("Replication status will be saved to the "
+ "[mysql:replication] section in %s",
+ self.config.filename)
+ self.config['mysqldump']['bin-log-position'] = False
+
+ if self.dry_run:
+ self._dry_run(volume, snapshot, datadir)
+ # do the normal mysqldump dry-run
+ return self.mysqldump_plugin.backup()
+
try:
snapshot.start(volume)
except CallbackFailuresError, exc:
@@ -116,11 +127,23 @@ def backup(self):
# Something failed in the snapshot process
raise BackupError(str(exc))
-def _dry_run(volume):
- """Implement dry-run for LVM snapshots. Not much to do here at the moment
- """
- LOG.info("[dry-run] Snapshotting %s/%s to %s/%s_snapshot",
+ def _dry_run(self, volume, snapshot, datadir):
+ """Implement dry-run for LVM snapshots.
+ """
+ LOG.info("* Would snapshot source volume %s/%s as %s/%s (size=%s)",
volume.vg_name,
volume.lv_name,
volume.vg_name,
- volume.lv_name)
+ snapshot.name,
+ format_bytes(snapshot.size*int(volume.vg_extent_size)))
+ LOG.info("* Would mount on %s",
+ snapshot.mountpoint or 'generated temporary directory')
+
+ snapshot_mountpoint = snapshot.mountpoint or tempfile.gettempdir()
+ if getmount(self.target_directory) == getmount(datadir):
+ LOG.error("Backup directory %s is on the same filesystem as "
+ "the source logical volume %s.",
+ self.target_directory, volume.device_name())
+ LOG.error("This will result in very poor performance and "
+ "has a high potential for failed backups.")
+ raise BackupError("Improper backup configuration for LVM.")

0 comments on commit 112796d

Please sign in to comment.