[mylvmbackup] [mylvmbackup 5/9] Incomplete suffix.
- From: "Robin H. Johnson" <robbat2@xxxxxxxxxx>
- To: mylvmbackup@xxxxxxxxxxxxx
- Date: Thu, 27 Sep 2007 05:31:33 -0700
Use a temporary suffix at the end of the file to indicate that it is incomplete.
---
TODO | 2 --
mylvmbackup.pl.in | 4 +++-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/TODO b/TODO
index 658c2da..f31b793 100644
--- a/TODO
+++ b/TODO
@@ -10,8 +10,6 @@ mylvmbackup TODO list:
- Allow splitting of archives. Could this be done by being able to modularize
the backup part and allowing multiple plugins in a pipe? E.g. a generic
splitting plugin that can split any archives.
- - Create tarballs with an extra suffix as .INCOMPLETE-$RANDOM first and
- remove the suffix upon completion of the backup
- Provide an option to back up my.cnf along with the tarball
- Ability to exclude the binlog/relay log
- Further clean up the code, better option and error handling
diff --git a/mylvmbackup.pl.in b/mylvmbackup.pl.in
index bdca04f..e350f74 100755
--- a/mylvmbackup.pl.in
+++ b/mylvmbackup.pl.in
@@ -394,6 +394,7 @@ sub _create_pos_file_single
sub do_backup_tar
{
my $tarball = $archivename.$tarfilesuffix;
+ my $tarballtmp = sprintf('%s.INCOMPLETE-%07d',$tarball,int(rand(2**16)));
log_msg ("Creating tar archive $tarball", LOG_INFO);
my $mountdir_rel = $mountdir;
$mountdir_rel =~ s/^$topmountdir//g;
@@ -401,10 +402,11 @@ sub do_backup_tar
my $pos_filename_rel = $posmountdir . '/' .
File::Basename::basename($pos_filename);
$pos_filename_rel =~ s/^$topmountdir//g;
$pos_filename_rel =~ s/^\/+//g;
- my $command = "$tar $tararg $tarball -C $topmountdir $mountdir_rel/$relpath
$tarsuffixarg";
+ my $command = "$tar $tararg $tarballtmp -C $topmountdir
$mountdir_rel/$relpath $tarsuffixarg";
$command .= " $pos_filename_rel" if (-f $pos_filename );
if ( system($command) == 0 )
{
+ rename $tarballtmp, $tarball;
log_msg ("DONE", LOG_INFO);
} else {
log_msg ("FAIL $!", LOG_ERR);
--
1.5.3
- References:
- [mylvmbackup] [mylvmbackup 0/9] mega-feature patchbomb
- From: Robin H. Johnson
Other related posts:
- » [mylvmbackup] [mylvmbackup 5/9] Incomplete suffix.
- [mylvmbackup] [mylvmbackup 0/9] mega-feature patchbomb
- From: Robin H. Johnson