#!/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"; }