Hi,
I have configured bacula for my home network consisting of 5 machines,
backing up on to a USB hard disk.
Initially, I configured it using the recommended configuration for hard
disks, that is, to mount the HDD externally to bacula (fstab or by the
desktop environment), but I found that this arrangement is too fragile,
and my backups were failing. Additionally, this runs on a server
machine, and there is no automounter (and I didn't want to install
autofs).
I noticed that there are directives in the storage daemon's Device
section to allow Bacula to mount and unmount media as required. I
figured that this looked like the solution to my problem. So I used the
following configuration in my device section:
Device {
Name = Backup_Drive_1
Media Type = "Backup_Drive_1"
Device Type = File
Archive Device = /dev/disk/by-label/Backup_Drive_1
Removable Media = yes;
Requires Mount = yes;
Mount Point = /media/Backup_Drive_1
Mount Command = "/usr/bin/pmount %a %m"
Unmount Command = "/usr/bin/pumount %a"
LabelMedia = yes;
Random Access = Yes;
AutomaticMount = yes;
}
(Note that, while this depends on udev to work properly, I didn't have
to configure udev to do anything it doesn't already do by itself.)
Unfortunately, this configuration doesn't work, because the storage
daemon looks for the volume files under the Archive Device path
/dev/disk/by-label/Backup_Drive_1
instead of the Mount Point path
/media/Backup_Drive_1
So, I patched the source code (see patch attached) to make the storage
daemon search for volume files in the mount path when the device
requires a mount. This has now resulted in a stable and robust system
for me. I can unplug the drive when bacula is not using it (I want to
set up an off-site rotation), and bacula will mount an available drive
when it needs it. And no manual intervention is required when the system
is rebooted.
The only inconvenience I see is that I have to manually create the mount
point before the storage daemon will start (because the storage daemon
checks that the mount point exists during startup). I have to do this as
part of configuring up a new backup drive. This check is sensible when
the Mount Command uses the traditional 'mount' program, but pmount
creates the mount point itself. So in this case the check is
un-necessary. I don't know how to resolve that, except perhaps to add
some new option to control the check, or to add new Pmount Command and
Punmount Command options that may be used in place of Mount Command and
Unmount Command.
I am unsure about how my change may affect the use of any other kinds of
'mountable' devices, or whether they may be triggered inappropriately in
other contexts. The device code seems to be used in so many different
ways for different types of hardware. I need a review by a more
experienced bacula developer.
I tried to follow your git instructions in the developers guide, but
they seem to be out of date. I got errors. The patch is simple, I have
attached it.
Ben Stanley.
Author: Ben Stanley <ben.stan...@exemail.com.au> 2012-04-25 23:37:53
Committer: Ben Stanley <ben.stan...@exemail.com.au> 2012-04-25 23:37:53
Parent: cb1c5bf5c5116d463d8c5675b415b2db0c15baff (Recompile configure.in)
Branch: Branch-5.2
Follows: Release-5.2.6
Precedes:
stored should store volumes in the mount path for mountable drives.
--------------------------- bacula/src/stored/dev.c ---------------------------
index 7c44a9f..1592737 100644
@@ -533,12 +533,21 @@ void DEVICE::open_file_device(DCR *dcr, int omode)
* Handle opening of File Archive (not a tape)
*/
- pm_strcpy(archive_name, dev_name);
- /*
- * If this is a virtual autochanger (i.e. changer_res != NULL)
- * we simply use the device name, assuming it has been
- * appropriately setup by the "autochanger".
- */
+ if ( requires_mount() ) {
+ /*
+ * If a removable usb drive is used, and it requires a mount,
+ * then volumes are placed in the mount point.
+ */
+ pm_strcpy(archive_name, device->mount_point);
+ } else {
+ /*
+ * If this is a virtual autochanger (i.e. changer_res != NULL)
+ * we simply use the device name, assuming it has been
+ * appropriately setup by the "autochanger".
+ */
+ pm_strcpy(archive_name, dev_name);
+ }
+
if (!device->changer_res || device->changer_command[0] == 0) {
if (VolCatInfo.VolCatName[0] == 0) {
Mmsg(errmsg, _("Could not open file device %s. No Volume name given.\n"),
@@ -551,6 +560,7 @@ void DEVICE::open_file_device(DCR *dcr, int omode)
pm_strcat(archive_name, "/");
}
pm_strcat(archive_name, getVolCatName());
+
}
mount(1); /* do mount if required */
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Bacula-devel mailing list
Bacula-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-devel