[otrs-cvs] otrs/scripts backup.pl,1.11,1.12 restore.pl,1.5,1.6

cvs-log at otrs.org cvs-log at otrs.org
Tue Apr 1 19:41:46 GMT 2008


Comments:
Update of /home/cvs/otrs/scripts
In directory lancelot:/tmp/cvs-serv566/scripts

Modified Files:
	backup.pl restore.pl 
Log Message:
Added win32 support.

Author: martin

Index: backup.pl
===================================================================
RCS file: /home/cvs/otrs/scripts/backup.pl,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** backup.pl	15 Oct 2007 14:55:34 -0000	1.11
--- backup.pl	1 Apr 2008 19:41:41 -0000	1.12
***************
*** 2,6 ****
  # --
  # scripts/backup.pl - the backup script
! # Copyright (C) 2001-2007 OTRS GmbH, http://otrs.org/
  # --
  # $Id$
--- 2,6 ----
  # --
  # scripts/backup.pl - the backup script
! # Copyright (C) 2001-2008 OTRS AG, http://otrs.org/
  # --
  # $Id$
***************
*** 51,57 ****
  if ( $Opts{'h'} ) {
      print "backup.pl <Revision $VERSION> - backup script\n";
!     print "Copyright (c) 2001-2007 OTRS GmbH, http//otrs.org/\n";
!     print
!         "usage: backup.pl -d /data_backup_dir/ [-c gzip|bzip2] [-r 30] [-t fullbackup|nofullbackup]\n";
      exit 1;
  }
--- 51,56 ----
  if ( $Opts{'h'} ) {
      print "backup.pl <Revision $VERSION> - backup script\n";
!     print "Copyright (c) 2001-2008 OTRS AG, http//otrs.org/\n";
!     print "usage: backup.pl -d /data_backup_dir/ [-c gzip|bzip2] [-r 30] [-t fullbackup|nofullbackup]\n";
      exit 1;
  }
***************
*** 115,119 ****
  if ( $DatabaseDSN =~ /:mysql/i ) {
      $DB     = 'MySQL';
!     $DBDump = 'mysqldump';
  }
  elsif ( $DatabaseDSN =~ /:pg/i ) {
--- 114,118 ----
  if ( $DatabaseDSN =~ /:mysql/i ) {
      $DB     = 'MySQL';
!     $DBDump = 'mysqldump5';
  }
  elsif ( $DatabaseDSN =~ /:pg/i ) {
***************
*** 183,189 ****
  # create new backup directory
  my $Home = $CommonObject{ConfigObject}->Get('Home');
! my ( $s, $m, $h, $D, $M, $Y )
!     = $CommonObject{TimeObject}
!     ->SystemTime2Date( SystemTime => $CommonObject{TimeObject}->SystemTime(), );
  my $Directory = "$Opts{'d'}/$Y-$M-$D" . "_" . "$h-$m";
  if ( !mkdir($Directory) ) {
--- 182,189 ----
  # create new backup directory
  my $Home = $CommonObject{ConfigObject}->Get('Home');
! chdir($Home);
! my ( $s, $m, $h, $D, $M, $Y ) = $CommonObject{TimeObject}->SystemTime2Date(
!     SystemTime => $CommonObject{TimeObject}->SystemTime(),
! );
  my $Directory = "$Opts{'d'}/$Y-$M-$D" . "_" . "$h-$m";
  if ( !mkdir($Directory) ) {
***************
*** 194,202 ****
  # backup Kernel/Config.pm
  print "Backup $Directory/Config.tar.gz ... ";
! if (!system(
!         "cd $Home && tar -czf $Directory/Config.tar.gz Kernel/Config.pm Kernel/Config/Files/ZZZA*.pm Kernel/Config/GenericAgen*.pm"
!     )
!     )
! {
      print "done\n";
  }
--- 194,198 ----
  # backup Kernel/Config.pm
  print "Backup $Directory/Config.tar.gz ... ";
! if (!system( "tar -czf $Directory/Config.tar.gz Kernel/Config.pm Kernel/Config/Files/ZZZA*.pm Kernel/Config/GenericAgen*.pm")) {
      print "done\n";
  }
***************
*** 208,212 ****
  if ($FullBackup) {
      print "Backup $Directory/Application.tar.gz ... ";
!     if ( !system("cd $Home && tar -czf $Directory/Application.tar.gz .") ) {
          print "done\n";
      }
--- 204,208 ----
  if ($FullBackup) {
      print "Backup $Directory/Application.tar.gz ... ";
!     if ( !system("tar -czf $Directory/Application.tar.gz .") ) {
          print "done\n";
      }
***************
*** 219,223 ****
  else {
      print "Backup $Directory/VarDir.tar.gz ... ";
!     if ( !system("cd $Home && tar -czf $Directory/VarDir.tar.gz var/") ) {
          print "done\n";
      }
--- 215,219 ----
  else {
      print "Backup $Directory/VarDir.tar.gz ... ";
!     if ( !system("tar -czf $Directory/VarDir.tar.gz var/") ) {
          print "done\n";
      }
***************
*** 230,234 ****
  if ( $ArticleDir !~ /\Q$Home\E/ ) {
      print "Backup $Directory/DataDir.tar.gz ... ";
!     if ( !system("cd $ArticleDir && tar -czf $Directory/DataDir.tar.gz .") ) {
          print "done\n";
      }
--- 226,230 ----
  if ( $ArticleDir !~ /\Q$Home\E/ ) {
      print "Backup $Directory/DataDir.tar.gz ... ";
!     if ( !system("tar -czf $Directory/DataDir.tar.gz .") ) {
          print "done\n";
      }
***************
*** 244,252 ****
          $DatabasePw = "-p$DatabasePw";
      }
!     if (!system(
!             "$DBDump -u $DatabaseUser $DatabasePw -h $DatabaseHost $Database > $Directory/DatabaseBackup.sql"
!         )
!         )
!     {
          print "done\n";
      }
--- 240,244 ----
          $DatabasePw = "-p$DatabasePw";
      }
!     if (!system( "$DBDump -u $DatabaseUser $DatabasePw -h $DatabaseHost $Database > $Directory/DatabaseBackup.sql")) {
          print "done\n";
      }
***************
*** 257,264 ****
  else {
      print "Dump $DB rdbms ... ";
!     if (!system(
!             "$DBDump -f $Directory/DatabaseBackup.sql -h $DatabaseHost -U $DatabaseUser $Database")
!         )
!     {
          print "done\n";
      }
--- 249,253 ----
  else {
      print "Dump $DB rdbms ... ";
!     if (!system( "$DBDump -f $Directory/DatabaseBackup.sql -h $DatabaseHost -U $DatabaseUser $Database")) {
          print "done\n";
      }

Author: martin

Index: restore.pl
===================================================================
RCS file: /home/cvs/otrs/scripts/restore.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** restore.pl	29 Sep 2007 11:10:47 -0000	1.5
--- restore.pl	1 Apr 2008 19:41:41 -0000	1.6
***************
*** 2,6 ****
  # --
  # scripts/restore.pl - the restore script
! # Copyright (C) 2001-2007 OTRS GmbH, http://otrs.org/
  # --
  # $Id$
--- 2,6 ----
  # --
  # scripts/restore.pl - the restore script
! # Copyright (C) 2001-2008 OTRS AG, http://otrs.org/
  # --
  # $Id$
***************
*** 42,46 ****
  if ( $Opts{'h'} ) {
      print "restore.pl <Revision $VERSION> - restore script\n";
!     print "Copyright (c) 2001-2007 OTRS GmbH, http://otrs.org/\n";
      print "usage: restore.pl -b /data_backup/<TIME>/ -d /opt/otrs/\n";
      exit 1;
--- 42,46 ----
  if ( $Opts{'h'} ) {
      print "restore.pl <Revision $VERSION> - restore script\n";
!     print "Copyright (c) 2001-2008 OTRS AG, http://otrs.org/\n";
      print "usage: restore.pl -b /data_backup/<TIME>/ -d /opt/otrs/\n";
      exit 1;
***************
*** 65,70 ****
  # restore config
  print "Restore $Opts{'b'}/Config.tar.gz ...\n";
  if ( -e "$Opts{'b'}/Config.tar.gz" ) {
!     system("cd $Opts{'d'} && tar -xzf $Opts{'b'}/Config.tar.gz");
  }
  
--- 65,71 ----
  # restore config
  print "Restore $Opts{'b'}/Config.tar.gz ...\n";
+ chdir($Opts{'d'});
  if ( -e "$Opts{'b'}/Config.tar.gz" ) {
!     system("tar -xzf $Opts{'b'}/Config.tar.gz");
  }
  
***************
*** 129,140 ****
          }
          if ($Check) {
!             print STDERR
!                 "ERROR: Already existing tables in this database. A empty database is required for restore!\n";
              exit(1);
          }
      }
      else {
!         $CommonObject{DBObject}->Prepare( SQL =>
!                 "SELECT table_name FROM information_schema.tables WHERE table_catalog = 'otrs' AND table_schema = 'public'",
          );
          my $Check = 0;
--- 130,140 ----
          }
          if ($Check) {
!             print STDERR "ERROR: Already existing tables in this database. A empty database is required for restore!\n";
              exit(1);
          }
      }
      else {
!         $CommonObject{DBObject}->Prepare(
!             SQL => "SELECT table_name FROM information_schema.tables WHERE table_catalog = 'otrs' AND table_schema = 'public'",
          );
          my $Check = 0;
***************
*** 143,148 ****
          }
          if ($Check) {
!             print STDERR
!                 "ERROR: Already existing tables in this database. A empty database is required for restore!\n";
              exit(1);
          }
--- 143,147 ----
          }
          if ($Check) {
!             print STDERR "ERROR: Already existing tables in this database. A empty database is required for restore!\n";
              exit(1);
          }
***************
*** 152,160 ****
  # restore
  my $Home = $CommonObject{ConfigObject}->Get('Home');
  
  # backup application
  if ( -e "$Opts{'b'}/Application.tar.gz" ) {
      print "Restore $Opts{'b'}/Application.tar.gz ...\n";
!     system("cd $Opts{'d'} && tar -xzf $Opts{'b'}/Application.tar.gz");
  }
  
--- 151,160 ----
  # restore
  my $Home = $CommonObject{ConfigObject}->Get('Home');
+ chdir($Home);
  
  # backup application
  if ( -e "$Opts{'b'}/Application.tar.gz" ) {
      print "Restore $Opts{'b'}/Application.tar.gz ...\n";
!     system("tar -xzf $Opts{'b'}/Application.tar.gz");
  }
  
***************
*** 162,166 ****
  if ( -e "$Opts{'b'}/VarDir.tar.gz" ) {
      print "Restore $Opts{'b'}/VarDir.tar.gz ...\n";
!     system("cd $Opts{'d'} && tar -xzf $Opts{'b'}/VarDir.tar.gz");
  }
  
--- 162,166 ----
  if ( -e "$Opts{'b'}/VarDir.tar.gz" ) {
      print "Restore $Opts{'b'}/VarDir.tar.gz ...\n";
!     system("tar -xzf $Opts{'b'}/VarDir.tar.gz");
  }
  
***************
*** 168,172 ****
  if ( -e "$Opts{'b'}/DataDir.tar.gz" ) {
      print "Restore $Opts{'b'}/DataDir.tar.gz ...\n";
!     system("cd $Opts{'d'} && tar -xzf $Opts{'b'}/DataDir.tar.gz");
  }
  
--- 168,172 ----
  if ( -e "$Opts{'b'}/DataDir.tar.gz" ) {
      print "Restore $Opts{'b'}/DataDir.tar.gz ...\n";
!     system("tar -xzf $Opts{'b'}/DataDir.tar.gz");
  }
  
***************
*** 181,187 ****
          system("gunzip $Opts{'b'}/DatabaseBackup.sql.gz");
          print "cat SQL-file into $DB database\n";
!         system(
!             "cat $Opts{'b'}/DatabaseBackup.sql | mysql -f -u$DatabaseUser $DatabasePw -h$DatabaseHost $Database"
!         );
          print "compress SQL-file...\n";
          system("gzip $Opts{'b'}/DatabaseBackup.sql");
--- 181,185 ----
          system("gunzip $Opts{'b'}/DatabaseBackup.sql.gz");
          print "cat SQL-file into $DB database\n";
!         system( "mysql -f -u$DatabaseUser $DatabasePw -h$DatabaseHost $Database < $Opts{'b'}/DatabaseBackup.sql");
          print "compress SQL-file...\n";
          system("gzip $Opts{'b'}/DatabaseBackup.sql");
***************
*** 191,197 ****
          system("bunzip $Opts{'b'}/DatabaseBackup.sql.bz2");
          print "cat SQL-file into $DB database\n";
!         system(
!             "cat $Opts{'b'}/DatabaseBackup.sql | mysql -f -u$DatabaseUser $DatabasePw -h$DatabaseHost $Database"
!         );
          print "compress SQL-file...\n";
          system("bzip $Opts{'b'}/DatabaseBackup.sql");
--- 189,193 ----
          system("bunzip $Opts{'b'}/DatabaseBackup.sql.bz2");
          print "cat SQL-file into $DB database\n";
!         system( "mysql -f -u$DatabaseUser $DatabasePw -h$DatabaseHost $Database < $Opts{'b'}/DatabaseBackup.sql");
          print "compress SQL-file...\n";
          system("bzip $Opts{'b'}/DatabaseBackup.sql");
***************
*** 203,208 ****
          system("gunzip $Opts{'b'}/DatabaseBackup.sql.gz");
          print "cat SQL-file into $DB database\n";
!         system(
!             "cat $Opts{'b'}/DatabaseBackup.sql | psql -u$DatabaseUser -h$DatabaseHost $Database");
          print "compress SQL-file...\n";
          system("gzip $Opts{'b'}/DatabaseBackup.sql");
--- 199,203 ----
          system("gunzip $Opts{'b'}/DatabaseBackup.sql.gz");
          print "cat SQL-file into $DB database\n";
!         system( "cat $Opts{'b'}/DatabaseBackup.sql | psql -u$DatabaseUser -h$DatabaseHost $Database");
          print "compress SQL-file...\n";
          system("gzip $Opts{'b'}/DatabaseBackup.sql");
***************
*** 212,217 ****
          system("bunzip $Opts{'b'}/DatabaseBackup.sql.bz2");
          print "cat SQL-file into $DB database\n";
!         system(
!             "cat $Opts{'b'}/DatabaseBackup.sql | psql -u$DatabaseUser -h$DatabaseHost $Database");
          print "compress SQL-file...\n";
          system("bzip $Opts{'b'}/DatabaseBackup.sql");
--- 207,211 ----
          system("bunzip $Opts{'b'}/DatabaseBackup.sql.bz2");
          print "cat SQL-file into $DB database\n";
!         system( "cat $Opts{'b'}/DatabaseBackup.sql | psql -u$DatabaseUser -h$DatabaseHost $Database");
          print "compress SQL-file...\n";
          system("bzip $Opts{'b'}/DatabaseBackup.sql");


More information about the cvs-log mailing list