[mylvmbackup] [mylvmbackup 2/9] Cleanup of variables.
- From: "Robin H. Johnson" <robbat2@xxxxxxxxxx>
- To: mylvmbackup@xxxxxxxxxxxxx
- Date: Thu, 27 Sep 2007 05:30:58 -0700
Clean up variable ordering and manpage to ensure that all arguments/configopts
are documented.
The config file still needs loving.
---
man/mylvmbackup.1.txt | 31 ++++++++++++--
mylvmbackup.pl.in | 103 ++++++++++++++++++++++++++++--------------------
2 files changed, 86 insertions(+), 48 deletions(-)
diff --git a/man/mylvmbackup.1.txt b/man/mylvmbackup.1.txt
index 66c98ac..89e16d6 100644
--- a/man/mylvmbackup.1.txt
+++ b/man/mylvmbackup.1.txt
@@ -113,11 +113,20 @@ the leading dashes, of course).
--lvcreate=string::
Specifies the pathname for the 'lvcreate' program.
- The default is '/sbin/lvcreate'.
+ The default is 'lvcreate'.
--lvremove=string::
Specifies the pathname for the 'lvremove' program.
- The default is '/sbin/lvremove'.
+ The default is 'lvremove'.
+
+--lvs=string::
+ Specifies the pathname for the 'lvs' program.
+ The default is 'lvs'.
+
+--mysqld_safe=string::
+ Specifies the pathname for the 'mysqld_safe' program.
+ The default is 'mysqld_safe'.
+ Only used to perform InnoDB recovery.
--vgname=string::
Specifies the volume group of the logical volume where the MySQL
@@ -129,6 +138,10 @@ the leading dashes, of course).
directory is located.
The default is 'data'.
+--backuplv=string::
+ Specifies the name of the logical volume for the snapshot volume.
+ The default is appending "_snapshot" to the lvname.
+
--relpath=string::
Relative path on the logical volume to the MySQL data directory.
The default is the empty string.
@@ -160,15 +173,23 @@ the leading dashes, of course).
--mount=string::
Specifies the pathname for the 'mount' program.
- The default is '/bin/mount'.
+ The default is 'mount'.
--umount=string::
Specifies the pathname for the 'umount' program.
- The default is '/bin/umount'.
+ The default is 'umount'.
--tar=string::
Specifies the pathname for the 'tar' program.
- The default is '/bin/tar'.
+ The default is 'tar'.
+
+--tararg=string::
+ Specifies the initial arguments for the 'tar' program.
+ The default is 'cvzf'.
+
+--tarsuffixarg=string::
+ Specifies the suffix arguments for the 'tar' program.
+ The default is ''.
--xfs::
Use the 'nouuid' mount option to safely mount snapshot partitions that
diff --git a/mylvmbackup.pl.in b/mylvmbackup.pl.in
index cf46a14..d3fb642 100755
--- a/mylvmbackup.pl.in
+++ b/mylvmbackup.pl.in
@@ -215,6 +215,7 @@ log_msg ("Cleaning up...", LOG_INFO);
cleanup();
exit 0;
+# Please keep all 3 functions in the same order: load_config, load_args,
load_defaults
sub load_config
{
my $configfile = shift(@_);
@@ -228,33 +229,30 @@ sub load_config
$socket = $cfg->val ('mysql', 'socket', $socket);
$mysqld_safe = $cfg->val ('mysql', 'mysqld_safe', $mysqld_safe);
- $need_xfsworkaround=$cfg->val ('fs', 'xfs', $need_xfsworkaround);
-
$vgname=$cfg->val ('lvm', 'vgname', $vgname);
- $prefix=$cfg->val ('misc', 'prefix', $prefix);
$lvname=$cfg->val ('lvm', 'lvname', $lvname);
+ $lvsize=$cfg->val ('lvm', 'lvsize', $lvsize);
+ $backuplv = $cfg->val ('lvm', 'backuplv', $backuplv);
+
+ $prefix=$cfg->val ('misc', 'prefix', $prefix);
$datefmt=$cfg->val ('misc', 'datefmt', $datefmt);
$innodb_recover=$cfg->val ('misc', 'innodb_recover', $innodb_recover);
$pidfile=$cfg->val ('misc', 'pidfile', $pidfile);
$skip_flush_tables=$cfg->val ('misc', 'skip_flush_tables',
$skip_flush_tables);
-
- $relpath=$cfg->val ('fs', 'relpath', $relpath);
-
- $lvsize=$cfg->val ('lvm', 'lvsize', $lvsize);
$tararg=$cfg->val ('misc', 'tararg', $tararg);
$tarsuffixarg=$cfg->val ('misc', 'tarsuffixarg', $tarsuffixarg);
$mountdir=$cfg->val ('fs', 'mountdir', $mountdir);
$backupdir=$cfg->val ('fs', 'backupdir', $backupdir);
+ $relpath=$cfg->val ('fs', 'relpath', $relpath);
+ $need_xfsworkaround=$cfg->val ('fs', 'xfs', $need_xfsworkaround);
$lvcreate=$cfg->val ('tools', 'lvcreate', $lvcreate);
$lvremove=$cfg->val ('tools', 'lvremove', $lvremove);
$lvs=$cfg->val ('tools', 'lvs', $lvs);
$mount=$cfg->val ('tools', 'mount', $mount);
- $tar=$cfg->val ('tools', 'tar', $tar);
$umount=$cfg->val ('tools', 'umount', $umount);
-
- $backuplv = $cfg->val ('lvm', 'backuplv', $backuplv);
+ $tar=$cfg->val ('tools', 'tar', $tar);
$log_method = $cfg->val('logging', 'log_method', $log_method);
$syslog_socktype = $cfg->val ('logging', 'syslog_socktype',
$syslog_socktype);
@@ -262,81 +260,100 @@ sub load_config
$syslog_remotehost = $cfg->val ('logging', 'syslog_remotehost',
$syslog_remotehost);
}
+# Please keep all 3 functions in the same order: load_config, load_args,
load_defaults
sub load_args
{
GetOptions(
- "backupdir=s" => \$backupdir,
- "backuplv=s" => \$backuplv,
- "datefmt=s" => \$datefmt,
+# stuff that doesn't go in the config file ;-)
"help" => \&help,
+ "configfile=s" => \$configfile2,
+
+# mysql
+ "user=s" => \$user,
+ "password=s" => \$password,
"host=s" => \$host,
- "innodb_recover" => \&innodb_recover,
- "lvcreate=s" => \$lvcreate,
+ "port=i" => \$port,
+ "socket=s" => \$socket,
+ "mysqld_safe=s" => \$mysqld_safe,
+
+# lvm
+ "vgname=s" => \$vgname,
"lvname=s" => \$lvname,
- "lvremove=s" => \$lvremove,
- "lvs=s" => \$lvs,
"lvsize=s" => \$lvsize,
- "mountdir=s" => \$mountdir,
- "mount=s" => \$mount,
- "password=s" => \$password,
- "pidfile=s" => \$pidfile,
- "port=i" => \$port,
+ "backuplv=s" => \$backuplv,
+
+# misc
"prefix=s" => \$prefix,
- "relpath=s" => \$relpath,
- "socket=s" => \$socket,
+ "datefmt=s" => \$datefmt,
+ "innodb_recover" => \&innodb_recover,
+ "pidfile=s" => \$pidfile,
+ "skip_flush_tables" => \&skip_flush_tables,
"tararg=s" => \$tararg,
"tarsuffixarg=s" => \$tarsuffixarg,
- "tar=s" => \$tar,
- "umount=s" => \$umount,
- "user=s" => \$user,
- "vgname=s" => \$vgname,
+
+# fs
+ "mountdir=s" => \$mountdir,
+ "backupdir=s" => \$backupdir,
+ "relpath=s" => \$relpath,
"xfs" => \&need_xfsworkaround,
+
+# tools
+ "lvcreate=s" => \$lvcreate,
+ "lvremove=s" => \$lvremove,
+ "lvs=s" => \$lvs,
+ "mount=s" => \$mount,
+ "umount=s" => \$umount,
+ "tar=s" => \$tar,
+
+# logging
"log_method=s" => \$log_method,
- "skip_flush_tables" => \&skip_flush_tables,
"syslog_socktype=s" => \$syslog_socktype,
"syslog_facility=s" => \$syslog_facility,
"syslog_remotehost=s" => \$syslog_remotehost,
- "configfile=s" => \$configfile2,
) or help();
}
+# Please keep all 3 functions in the same order: load_config, load_args,
load_defaults
sub load_defaults
{
+# mysql
$user = 'root';
$password = '';
$host = '';
$port = 3306;
$socket = '';
- $pidfile = '/var/tmp/mylvmbackup_recoverserver.pid';
-
- $need_xfsworkaround=0;
-
- $innodb_recover=0;
- $skip_flush_tables=0;
+ $mysqld_safe='mysqld_safe';
+# lvm
$vgname='mysql';
- $prefix='backup';
$lvname='data';
- $datefmt='%Y%m%d_%H%M%S';
-
- $relpath='';
$lvsize='5G';
+ $backuplv = '';
+
+# misc
+ $prefix='backup';
+ $datefmt='%Y%m%d_%H%M%S';
+ $innodb_recover=0;
+ $pidfile = '/var/tmp/mylvmbackup_recoverserver.pid';
+ $skip_flush_tables=0;
$tararg='cvzf';
$tarsuffixarg='';
+# fs
$mountdir='/var/tmp/mylvmbackup/mnt/';
$backupdir='/var/tmp/mylvmbackup/backup/';
+ $relpath='';
+ $need_xfsworkaround=0;
+# tools
$lvcreate='lvcreate';
$lvremove='lvremove';
$lvs='lvs';
$mount='mount';
$umount='umount';
$tar='tar';
- $mysqld_safe='mysqld_safe';
-
- $backuplv = '';
+# logging
$log_method = 'console';
$syslog_socktype = 'native';
$syslog_facility = '';
--
1.5.3
- References:
- [mylvmbackup] [mylvmbackup 0/9] mega-feature patchbomb
- From: Robin H. Johnson
Other related posts:
- » [mylvmbackup] [mylvmbackup 2/9] Cleanup of variables.
- [mylvmbackup] [mylvmbackup 0/9] mega-feature patchbomb
- From: Robin H. Johnson