Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /svnutils/branches/dvl-sunny/src/

svnutils
Discussion topic

Back to topic list

CVS update: /svnutils/branches/dvl-sunny/src/

Author sunny
Full name Øyvind A. Holm
Date 2004-06-06 19:26:31 PDT
Message User: sunny
Date: 04/06/06 19:26:31

Modified:
 /svnutils/branches/d​vl-sunny/src/
  svnbck

Log:
 r31 | sunny | 2004-06-07 04:25:13 +0200 (Mon, 07 Jun 2004) | 9 lines
 
 * branches/dvl-sunny/src/svnbck
   Some changes done on 2004-06-01 07:39:56Z :
   - use Getopt::Std, it reads the -h (help) and -f (configuration file)
     option.
   - Added lots of POD, it now creates a man page and there is a big
     THOUGHTS section with some design planning.
   - $prog_name is properly stripped.
   - Added usage() and started on parse_config_file().

File Changes:

Directory: /svnutils/branches/d​vl-sunny/src/
====================​====================​====

File [changed]: svnbck
Url: http://svnutils.tigr​is.org/source/browse​/svnutils/branches/d​vl-sunny/src/svnbck?​r1=1.1&r2=1.2
Delta lines: +190 -34
----------------------
--- svnbck 25 May 2004 05:01:03 -0000 1.1
+++ svnbck 7 Jun 2004 02:26:31 -0000 1.2
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 
 #===================​====================​====================​====
-# $Id: svnbck 26 2004-05-25 04:59:39Z sunny $
+# $Id: svnbck 31 2004-06-07 02:25:13Z sunny $
 # Backup of active Subversion repositories
 #
 # Character set: UTF-8
@@ -10,15 +10,21 @@
 #===================​====================​====================​====
 
 use strict;
+# use utf8; # I don’t like this, it slows down Perl and tastes kludgy. If you are in a non-UTF-8 locale, it should probably be uncommented.
 use Env qw{HOME};
+use Getopt::Std;
+our ($opt_f, $opt_h) =
+ ("", 0 );
 
 $| = 1;
 
+getopts('f:h') || die("Option error. Use -h for help.");
+
 my $Simulate = 1;
 
 my $prog_name = $0;
-$prog_name =~ s/\/(.*?)$/$1/;
-my $svn_Id = '$Id: svnbck 26 2004-05-25 04:59:39Z sunny $';
+$prog_name =~ s/^(.*\/)(.*?)$/$2/;
+my $svn_Id = '$Id: svnbck 31 2004-06-07 02:25:13Z sunny $';
 $svn_Id =~ s/^\$Id: (.*) \$/$1/;
 my ($rev_nr, $rev_date) =
    ("", "" );
@@ -27,56 +33,206 @@
     $rev_date = $3;
 }
 
+my @repos_array = ();
+
+$opt_h && usage(0);
+
 print("$prog_name r$rev_nr ($rev_date)\n");
+print("\nSorry ma, ain’t workin’ yet.\n");
 exit;
 
 defined($HOME) || die("$prog_name: The HOME environment variable is not defined. Aborting...\n");
 
-my $config_file = "$HOME/.backupsvnrc";
-my $reposconf_found = 0;
+my $config_file = length($opt_f) ? $opt_f : "$HOME/.svnbckrc";
+
+my $rcs_id = '$Id: svnbck 31 2004-06-07 02:25:13Z sunny $';
+$rcs_id =~ s/\$Id: (.*) \$/$1/;
+
+parse_config_file();
+
+sub mysystem {
+ # Wrapper around the system() call to enable simulation {{{
+ chomp(my $Cmd = shift);
+ if ($Simulate) {
+ print("Simulating \"$Cmd\"\n");
+ } else {
+ print("Executing \"$Cmd\"\n");
+ # system($Cmd);
+ }
+ # }}}
+} # mysystem()
 
-if (open(ConfigFP, "<$config_file")) {
+sub parse_config_file {
+ my $repos_found = 0;
+ if (open(ConfigFP, "<$config_file")) {
     while (<ConfigFP>) {
+ chomp();
+ s/\s+$//g;
         if (/^[repositories]/) {
- $reposconf_found = 1;
+ $repos_found = 1;
         } else {
+ if ($repos_found) {
+ if (/^(.+)$/) {
+ push(@repos_array, glob($1));
         }
+ } else {
+
     }
-} else {
+ }
+ }
+ } else {
     die("$prog_name: $config_file: Unable to open configuration file for read\n");
-}
+ }
+} # parse_config_file()
 
--e "/sunba.mrk" || die("Saken må kjøres på sunba.");
+sub usage {
+ # Prints a help screen {{{
+ my $Retval = shift;
+ print(<<END);
 
-my $rcs_id = '$Id: svnbck 26 2004-05-25 04:59:39Z sunny $';
-$rcs_id =~ s/\$Id: (.*) \$/$1/;
+$prog_name r$rev_nr ($rev_date)
+
+Syntac: $prog_name [options]
+
+Please refer to the POD (Plain Old Documentation) inside the $0 Perl script.
+You can create a man page from this documentation by executing
+
+ pod2man $0 >$0.1
+
+END
+ exit($Retval);
+ # }}}
+} usage()
+
+__END__
+
+# POD — Plain Old Documentation {{{
 
 =pod
 
-=head1 Plan for opplegget
+=head1 NAME
 
-cd ~/Svn
-glob alle filene i ~/Svn
+svnbck -- Backup utility for Subversion repositories
 
-for (@glob_array) {
- my $Curr = $_;
+=head1 REVISION
 
- mysystem("svnadmin
-}
+$Id: svnbck 31 2004-06-07 02:25:13Z sunny $
+
+=head1 SYNOPSIS
+
+svnbck [options]
+
+=head1 DESCRIPTION
+
+A frontend against svn that will create dumpfiles in various ways, based on configuration options in config files.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-f x>
+
+Use x as configuration file instead of F<~/.svnbckrc> .
+
+=item B<-h>
+
+Print a help message.
+
+=back
+
+=head1 FILES
 
+=over 4
+
+=item F<~/.svnbckrc>
+
+Default configuration file
+
+=back
+
+=head1 BUGS
+
+Well, it is unfinished at the moment.
+
+=head1 COPYRIGHT
+
+Copyright © 2004 Free Software Foundation, Inc.
+This is free software; see the file F<COPYING> for legalese stuff.
+
+=head1 AUTHOR
+
+Øyvind A. Holm E<lt>sunny@sun​base.orgE<gt>
+
+=head1 LICENCE
+
+GNU General Public License.
+The greatest of them all.
+Thanks, RMS.
+
+=head1 SEE ALSO
+
+svn(1)
 
 =cut
 
-sub mysystem {
- chomp(my $Cmd = shift);
- if ($Simulate) {
- print("Simulating \"$Cmd\"\n");
- } else {
- print("Executing \"$Cmd\"\n");
- # system($Cmd);
- }
-}
-__END__
+# }}}
+
+# Thoughts (POD) {{{
+
+=head1 THOUGHTS
+
+=head2 Format of the ~/.svnbckrc file
+
+All configuration options should be kept in this (or any other) config file.
+Several repositories can be specified under the [repositories] section, and exactly one is allowed/needed in the [destdir] section.
+
+The [blabla] format is used as section headers to follow the F<~/.subversion/config> style.
+
+ # This is a comment. The # has to be in the first column.
+
+ [repositories]
+
+ /full/path/to/repos1
+ /full/path/to/repos2
+ /full/path/to/repos3
+ /another/path/with/wildcards/*
+
+Only one destination dir is allowed at the moment.
+
+ [destdir]
+ # strftime(3) time specifiers can be inserted into the destination directory.
+ # Specifiers available:
+ # %Y Year with four digits
+ # %m Month (00..12)
+ # %d Day of month (00..31)
+ # %H Hour (00..23)
+ # %M Minutes (00..59)
+ # %S Seconds (00..61)
+ # %% Regular percent sign
+ # At the moment only GMT is used.
+ /home/user/reposback​up/%Y/%Y-%m-%d
+
+ [options]
+
+ # backup_format is B<dump> for regular dump files, or B<repository> for repository.
+ backup_format = dump
+
+ # incremental can be B<yes> or B<no> to enable/disable incremental backups.
+ # When backup_format = repository an error will be generated if incremental = yes.
+ incremental = yes
+
+ # The dump files can be compressed after backup. Available options are gzip, bzip2 or none.
+ compression = gzip
+
+ # notify_emails is where backup reports is sent
+ notify_emails = user1 at example dot com, user2 at tigris dot org, user3 at example dot com
+
+ # Logging of the backups is also available.
+ logfile = /foo/bar/logfiles/%Y​/reposbackup.log
+
+=cut
+
+# }}}
 
 # vim: set fileencoding=UTF-8 filetype=perl foldmethod=marker foldlevel=0 :
-# End of file $Id: svnbck 26 2004-05-25 04:59:39Z sunny $
+# End of file $Id: svnbck 31 2004-06-07 02:25:13Z sunny $




--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@svnu​tils.tigris.org
For additional commands, e-mail: cvs-help at svnutils dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /svnutils/branches/dvl-sunny/src/ sunny Øyvind A. Holm 2004-06-06 19:26:31 PDT
Messages per page: