diff options
author | Gunnar Wrobel <wrobel@gentoo.org> | 2005-09-03 08:53:56 +0000 |
---|---|---|
committer | Gunnar Wrobel <wrobel@gentoo.org> | 2005-09-03 08:53:56 +0000 |
commit | 4021c4cc9bd38bbff9e308545b6c278e68f0c8b0 (patch) | |
tree | ff98ea5b1c371213d719fd1518e469473b4ccc91 /z-distfiles/scripts-gw/SVN-dump | |
parent | These are the rearrangements (diff) | |
download | misc-4021c4cc9bd38bbff9e308545b6c278e68f0c8b0.tar.gz misc-4021c4cc9bd38bbff9e308545b6c278e68f0c8b0.tar.bz2 misc-4021c4cc9bd38bbff9e308545b6c278e68f0c8b0.zip |
Preparing new scripts-gw release
svn path=/local/; revision=331
Diffstat (limited to 'z-distfiles/scripts-gw/SVN-dump')
-rwxr-xr-x | z-distfiles/scripts-gw/SVN-dump | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/z-distfiles/scripts-gw/SVN-dump b/z-distfiles/scripts-gw/SVN-dump new file mode 100755 index 0000000..a812774 --- /dev/null +++ b/z-distfiles/scripts-gw/SVN-dump @@ -0,0 +1,79 @@ +#!/usr/bin/perl -w + +use strict; + +my $repos_path = $ARGV[0]; +my $dumpfile = $ARGV[1]; +my $type = $ARGV[2]; + +my $bin_svnadmin = `which svnadmin`; +my $bin_svnlook = `which svnlook`; +my $bin_bz2 = `which bzip2`; + +$bin_svnlook =~ s/\n//; +$bin_svnadmin =~ s/\n//; +$bin_bz2 =~ s/\n//; + +if ($bin_svnadmin eq "") {$bin_svnadmin = "/usr/bin/svnadmin"}; +if ($bin_svnlook eq "") {$bin_svnlook = "/usr/bin/svnlook"}; +if ($bin_bz2 eq "") {$bin_bz2 = "/bin/bzip2"}; + +# Figure out the starting revision. Use 0 if we cannot read the +# last-dumped file, else use the revision in that file incremented +# by 1. +my $new_start = 0; +if (open LASTDUMPED, "$dumpfile.last") +{ + my $line = <LASTDUMPED>; + if (defined $line and $line =~ /^(\d+)/) + { + $new_start = $1 + 1; + } + close LASTDUMPED; +} + +# Query the youngest revision in the repos. +my $youngest = `$bin_svnlook youngest $repos_path`; +defined $youngest && $youngest =~ /^\d+$/ + or die "$0: 'svnlook youngest $repos_path' cannot get youngest revision.\n"; +chomp $youngest; + +if ($type eq "incremental") +{ + if ($new_start > $youngest) + { + print "Nothing to do!\n"; + } else { + ## Do the backup. + system("$bin_svnadmin dump $repos_path --revision $new_start:$youngest --incremental >> $dumpfile.tmp") == 0 + or die "$0: svnadmin dump to '$dumpfile.tmp' failed.\n"; + + # Store a new last-dumped revision. + open LASTDUMPED, "> $dumpfile.last.tmp" + or die "$0: cannot open '$dumpfile.last.tmp' for writing: $!\n"; + print LASTDUMPED "$youngest\n"; + close LASTDUMPED + or die "$0: error in closing '$dumpfile.last.tmp' for writing: $!\n"; + + # Rename to final locations. + rename("$dumpfile.tmp", "$dumpfile.$new_start.$youngest") + or die "$0: cannot rename '$dumpfile.tmp' to '$dumpfile': $!\n"; + + rename("$dumpfile.last.tmp", "$dumpfile.last") + or die "$0: cannot rename '$dumpfile.last.tmp' to '$dumpfile.last': $!\n"; + + system("$bin_bz2 $dumpfile.$new_start.$youngest") == 0 + or die "$0: compressing dump file $dumpfile.$new_start.$youngest failed.\n"; + } +} else { + + system("$bin_svnadmin dump $repos_path >> $dumpfile.full.tmp") == 0 + or die "$0: svnadmin dump to '$dumpfile.tmp' failed.\n"; + + rename("$dumpfile.full.tmp", "$dumpfile.full") + or die "$0: cannot rename '$dumpfile.full.tmp' to '$dumpfile.full': $!\n"; + + system("$bin_bz2 -f $dumpfile.full") == 0 + or die "$0: compressing dump file $dumpfile.full failed.\n"; +} +# All done! |