[mylvmbackup] date format expanding proposal
- From: "Boehm, Matthew" <mboehm@xxxxxxxxxxxxx>
- To: <mylvmbackup@xxxxxxxxxxxxx>
- Date: Fri, 5 Sep 2008 11:24:17 -0500
If the path to where we want our backups to end up contains a pattern
support by Date::Format, parse it.
So if $backup_dir = "/var/backups/%Y%m%d/" then the expanded path would
be, /var/backups/20080905/.
[root@15000Dmys01 trunk]# bzr diff
=== modified file 'trunk/mylvmbackup.pl.in'
--- trunk/mylvmbackup.pl.in 2008-09-03 20:06:47 +0000
+++ trunk/mylvmbackup.pl.in 2008-09-05 16:19:20 +0000
@@ -733,12 +733,14 @@
#
# 1. Remove any whitespace padding first
# 2. Remove trailing slashes
+# 3. If path contains date pattern from Date::Format, expand it.
#
sub clean_dirname
{
my ($d) = @_;
$d =~ s/^\s*//g;
$d =~ s/\s$//g;
+ $d = time2str($d, time) if($d =~
/(%[aAbBcCdeDGhHIjklLmMnopPqrRsStTUwWxXyYZz])+/)
return File::Basename::dirname($d.'/foo')
}
Matthew Boehm
Senior MySQL DBA, The Planet - Northstar Managed Hosting
Certified MySQL 5.0 DBA
Office: 281-714-4018
Mobile: 832-253-8258
Email: mboehm@xxxxxxxxxxxxx
Other related posts:
- » [mylvmbackup] date format expanding proposal