#!/usr/bin/perl -w use strict; use warnings; #Variables my $fbbin = "/opt/firebird/bin/"; my $data = "/opt/databases/"; my $ext = "gdb"; #my $shared = "/opt/shared/"; my $tempdir = "/opt/backup/"; #my $destdir = "/home/mery/backup/complete/"; #my $usbdev = "/dev/sdc1/"; #my $localdir = "/mnt/storage/testy/"; #my $mailerr = "core-powiadomienia\@core.com.pl"; my $klient = "PanTester"; my $mailtopic = "Raport nocnej kopii zapasowej w firmie $klient"; use POSIX(); print POSIX::strftime('%Y-%m-%d-%H-%M-%S', localtime); #Create database filenames table @files my $type = $ext; my $dir = $data; $type = "*.$type"; print "looking for files with extension $type \n"; chdir ($dir); my @files = qx(ls $type 2>&1); foreach (@files) { print "Found database: $_\n"; } # This loop run external gbak backup command to create $_.gbk files as output in $tempdir foreach (@files) { chdir ($fbbin); # print "Tworze kopie bazy $_ \n"; system("./gbak -user sysdba -password masterkey -BACKUP_DATABASE localhost\:$data$_ $tempdir`$_.gbk`") or die "Blad archiwizowania bazy $_ \n"; # print "Gotowa kopia bazy $_ \n"; } #### 2012-02-28-22-23-33looking for files with extension *.gdb Found database: demo2.gdb Found database: demo.gdb Found database: SimpleMarketing2.gdb Found database: simplemarketing.gdb gbak: ERROR:requires both input and output filenames gbak:Exiting before completion due to errors sh: 1: demo2.gdb: not found sh: 2: .gbk: not found sh: 3: /opt/backup/: Permission denied gbak: ERROR:requires both input and output filenames gbak:Exiting before completion due to errors sh: 1: demo.gdb: not found sh: 2: .gbk: not found sh: 3: /opt/backup/: Permission denied gbak: ERROR:requires both input and output filenames gbak:Exiting before completion due to errors sh: 1: SimpleMarketing2.gdb: not found sh: 2: .gbk: not found sh: 3: /opt/backup/: Permission denied gbak: ERROR:requires both input and output filenames gbak:Exiting before completion due to errors sh: 1: simplemarketing.gdb: not found sh: 2: .gbk: not found sh: 3: /opt/backup/: Permission denied