--- /dev/null
+#!/bin/sh
+# This script is to create a summary of the job notifications from bacula
+# and send it to people who care.
+#
+# For it to work, you need to have all Bacula job report
+# mails cc'd to a unix mailbox called 'bacula', but of course you can edit
+# as appropriate. This should be run after all backup jobs have finished.
+# Tested with bacula-1.38.0
+
+# Contributed by Andrew J. Millar <andrew@alphajuliet.org.uk>
+
+# Use awk to create the report, pass to column to be
+# formatted nicely, then on to mail to be sent to
+# people who care.
+EMAIL_LIST="peoplewhocare@company.com"
+awk -F\:\ 'BEGIN {
+ print "Client Status Type StartTime EndTime Files Bytes"
+ }
+ /Client/ {
+ CLIENT=$2; sub(/"/, "", CLIENT) ; sub(/".*$/, "", CLIENT)
+ }
+ /Backup Level/ {
+ TYPE=$2 ; sub(/,.*$/, "", TYPE)
+ }
+ /Start time/ {
+ STARTTIME=$2; sub(/.*-.*-.* /, "", STARTTIME)
+ }
+ /End time/ {
+ ENDTIME=$2; sub(/.*-.*-.* /, "", ENDTIME)
+ }
+ /SD Files Written/ {
+ SDFILES=$2
+ }
+ /SD Bytes Written/ {
+ SDBYTES=$2
+ }
+ /Termination/ {
+ TERMINATION=$2 ;
+ sub(/Backup/, "", TERMINATION) ;
+ printf "%s %s %s %s %s %s %s \n", CLIENT,TERMINATION,TYPE,STARTTIME,ENDTIME,SDFILES,SDBYTES}' /var/spool/mail/bacula | \
+ column -t | \
+ mail -s "Bacula Summary for `date -d yesterday +%a,\ %D`" ${EMAIL_LIST}
+#
+# Empty the mailbox
+cat /dev/null > /var/spool/mail/bacula
+#
+# That's all folks
General:
Changes to 1.38.1:
+14Oct05
+- Apply SunOS patch for ACLs submitted by David Duchscher.
+- Make sure to set storage before trying to set drive.
+- Add bacula_mail_summary.sh to examples directory. It makes
+ a single email summary of any number of jobs. Submitted
+ by Adrew J. Millar.
+- Make sure when we do a mount to unblock the device even
+ if the drive could not be opened.
13Oct05
+- Merge Scott's new spec files.
- Add doc on setting up Win32 environment variable supplied
by Kees van den Broek.
- Turn off API debug output unless debug set to avoid confusing
#include "bacula.h"
#include "filed.h"
-/* So we can free system allocated memory */
-#undef free
-#undef malloc
-#define malloc &* dont use malloc in this routine
#else
/*
|| !( defined(HAVE_LINUX_OS) \
|| defined(HAVE_FREEBSD_OS) \
|| defined(HAVE_DARWIN_OS) \
+ || defined(HAVE_IRIX_OS) \
+ || defined(HAVE_OSF1_OS) \
+ || defined(HAVE_SUN_OS) \
)
/* bacl_get() returns the lenght of the string, or -1 on error. */
if (acl(jcr->last_fname, GETACL, n, acls) == n) {
if ((acl_text = acltotext(acls, n)) != NULL) {
len = pm_strcpy(jcr->acl_text, acl_text);
- free(acl_text);
+ actuallyfree(acl_text);
free(acls);
return len;
}
if (!acls) {
return -1;
}
- if (acl(jcr->last_fname, SETACL, n, acls) != 0) {
- free(acls);
+ if (acl(jcr->last_fname, SETACL, n, acls) == -1) {
+ actuallyfree(acls);
return -1;
}
- free(acls);
+ actuallyfree(acls);
return 0;
}
stat = wait_for_sysop(dcr);
if (dev->poll) {
- Dmsg1(400, "Poll timeout in create append vol on device %s\n", dev->print_name());
+ Dmsg1(000, "Poll timeout in create append vol on device %s\n", dev->print_name());
continue;
}
Mmsg(dev->errmsg, _("Max time exceeded waiting to mount Storage Device %s for Job %s\n"),
dev->print_name(), jcr->Job);
Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
- Dmsg1(400, "Gave up waiting on device %s\n", dev->print_name());
+ Dmsg1(000, "Gave up waiting on device %s\n", dev->print_name());
return false; /* exceeded maximum waits */
}
continue;
Jmsg(jcr, M_WARNING, 0, _("pthread error in mount_next_volume stat=%d ERR=%s\n"), stat,
be.strerror(stat));
}
- Dmsg1(400, "Someone woke me for device %s\n", dev->print_name());
+ Dmsg1(000, "Someone woke me for device %s\n", dev->print_name());
/* If no VolumeName, and cannot get one, try again */
P(dev->mutex);
}
set_jcr_job_status(jcr, JS_Running);
dir_send_job_status(jcr);
- Dmsg0(400, "leave dir_ask_sysop_to_mount_create_appendable_volume\n");
+ Dmsg0(000, "leave dir_ask_sysop_to_mount_create_appendable_volume\n");
return true;
}
/* Use system open() */
while ((fd = ::open(dev_name, mode+nonblocking, MODE_RW)) < 0) {
berrno be;
- Dmsg2(100, "Open error errno=%d ERR=%s\n", errno, be.strerror());
- if (errno == EINTR || errno == EAGAIN) {
+ dev_errno = errno;
+ Dmsg5(050, "Open omode=%d mode=%x nonblock=%d error errno=%d ERR=%s\n",
+ omode, mode, nonblocking, errno, be.strerror());
+ if (dev_errno == EINTR || dev_errno == EAGAIN) {
Dmsg0(100, "Continue open\n");
continue;
}
/* Busy wait for specified time (default = 5 mins) */
- if (errno == EBUSY && timeout-- > 0) {
+ if (dev_errno == EBUSY && timeout-- > 0) {
Dmsg2(100, "Device %s busy. ERR=%s\n", print_name(), be.strerror());
bmicrosleep(1, 0);
continue;
}
/* IO error (no volume) try 10 times every 6 seconds */
- if (errno == EIO && ioerrcnt-- > 0) {
+ if (dev_errno == EIO && ioerrcnt-- > 0) {
bmicrosleep(5, 0);
Dmsg0(100, "Continue open\n");
continue;
}
- dev_errno = errno;
Mmsg2(errmsg, _("Unable to open device %s: ERR=%s\n"),
print_name(), be.strerror(dev_errno));
/* Stop any open timer we set */
bnet_fsend(dir, _("3901 open device failed: ERR=%s\n"),
strerror_dev(dev));
dev->open_nowait = false;
+ if (dev->dev_blocked == BST_UNMOUNTED) {
+ /* We blocked the device, so unblock it */
+ Dmsg0(100, "Unmounted. Unblocking device\n");
+ unblock_device(dev);
+ }
break;
}
dev->open_nowait = false;