/[scripts]/trunk/pgsql-git-backup.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/pgsql-git-backup.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 84 by dpavlin, Thu Sep 11 19:59:52 2008 UTC revision 85 by dpavlin, Thu Sep 11 20:16:05 2008 UTC
# Line 8  use warnings; Line 8  use warnings;
8  use strict;  use strict;
9    
10  use Getopt::Long;  use Getopt::Long;
11    use Fatal qw/:void open close mkdir chdir/;
12  my $git = '/tmp/pgsql-git-backup/';  my $git = '/tmp/pgsql-git-backup/';
13  my $verbose = 0;  my $verbose = 0;
14  my $database = '';  my $database = '';
# Line 32  sub git { Line 33  sub git {
33  }  }
34    
35  sub write_chunk {  sub write_chunk {
36          my $path = sprintf("%s/%02d%s.sql", $database, $nr++, $name);          my $path = sprintf("%s/%04d%s.sql", $database, $nr++, $name);
37          open(my $fh, '>', $path) or die "can't open file $path: $!";          open(my $fh, '>', $path) or die "can't open file $path: $!";
38          print $fh $d;          print $fh $d;
39          close($fh);          close($fh);
# Line 40  sub write_chunk { Line 41  sub write_chunk {
41          git "git-add '$path'";          git "git-add '$path'";
42  }  }
43    
44  if ( ! -e $git ) {  mkdir $git if ! -e $git;
45          mkdir $git or die "can't create $git: $!";  
46          git 'git-init-db';  chdir $git;
47  }  warn "## using $git\n" if $verbose;
48    
49  chdir($git) or die "can't chdir $git: $!";  git 'git-init-db' if ! -e "$git/.git";
50    
51  if ( ! -e $database ) {  if ( ! -e $database ) {
52          mkdir $database or die "can't create $database: $!";          mkdir $database;
53  #       git "git-add '$database'";  #       git "git-add '$database'";
54  #       git "git-commit -m 'added $database directory' $database";  #       git "git-commit -m 'added $database directory' $database";
55  }  }

Legend:
Removed from v.84  
changed lines
  Added in v.85

  ViewVC Help
Powered by ViewVC 1.1.26