{"id":62,"date":"2010-11-04T11:14:12","date_gmt":"2010-11-03T22:14:12","guid":{"rendered":"http:\/\/www.templesoft.co.nz\/blog\/?p=62"},"modified":"2026-04-08T08:19:31","modified_gmt":"2026-04-07T20:19:31","slug":"using-bacula-to-archive-data","status":"publish","type":"post","link":"https:\/\/templesoft.co.nz\/journal\/?p=62","title":{"rendered":"Using Bacula to archive data."},"content":{"rendered":"<h2>I hate tape!<\/h2>\n<p style=\"text-align: justify;\">Ever since those early days working as an operator, my least favourite job was changing the daily backup tape. Oh sure, if your company has loads of cash you could shell out for an autochanger, but none of the organisations I worked for were ever prepared to pony up the dosh for one of those when they had a tape-monkey to do it for them!<\/p>\n<p style=\"text-align: justify;\">With the cost per GB of storage dropping, backup up to disk was more of a reality and in looking around for something that could (a) Backup to disk (b) across the network and (c) was automated, I discovered &#8220;Bacula&#8221;.<\/p>\n<p style=\"text-align: justify;\">So out comes the Ubuntu 10.04 server install disk and away we go&#8230;<\/p>\n<h2 style=\"text-align: justify;\">Assumptions<\/h2>\n<p style=\"text-align: justify;\">The neat thing with bacula is that there are a many different scenarios you can cater for. I&#8217;m not a Bacula master, nor do I profess to know all the ins-and-outs of its configuration files. No. I started this with a plan, a plan to meet a requirement&#8230; so the configuration detailed below is what worked for me, to meet my needs. Its online more as a journal (so I can refer back to it if I ever need to rebuild it) than a claimed definitive HOWTO!!<\/p>\n<p style=\"text-align: justify;\">The &#8220;so called&#8221; plan is build a Bacula server than will backup remote clients, initially to storage local to the server, but later pointing it to my FreeNAS server.<\/p>\n<p style=\"text-align: justify;\">In this &#8220;journal&#8221; I&#8217;ll follow the following steps\/stages:<\/p>\n<ol>\n<li><strong>Stage One<\/strong>&#8211; Configuring the Bacula server\n<ul>\n<li>Install and configure Bacula without using &#8220;localhost&#8221;.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Stage Two<\/strong>&#8211; Backup <strong>local<\/strong> files to <strong>local<\/strong>storage.<\/li>\n<li><strong>Stage Three<\/strong>&#8211; Backup <strong>remote<\/strong> files to <strong>local<\/strong> storage.\n<ul>\n<li>Install and configure Bacula file daemon on <strong>remote<\/strong> machine.<\/li>\n<li>Backup <strong>remote<\/strong> files to <strong>local<\/strong> storage.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Stage Four<\/strong>&#8211; Backup <strong>remote<\/strong> files to <strong>remote<\/strong> storage.\n<ul>\n<li><strong class=\"warn\">TBA<\/strong>: Install and configure Bacula storage daemon on <strong>remote<\/strong> machine.<\/li>\n<li><strong class=\"warn\">TBA<\/strong>: Backup <strong>remote<\/strong> files to <strong>remote<\/strong> storage.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p style=\"text-align: justify;\">The <a href=\"http:\/\/www.bacula.org\/\">Bacula Home Page<\/a> contains the latest Bacula news and developments, or for more Bacula configuration options refer to the <a href=\"http:\/\/www.bacula.org\/en\/rel-manual\/index.html\">Bacula User&#8217;s Manual<\/a><\/p>\n<h2 style=\"text-align: justify;\">Base Install<\/h2>\n<p style=\"text-align: justify;\">The base install of Ubuntu server 10.04 took about 30mins, with standard configuration and stopping &#8220;network auto-discovery&#8221; to declare a static IP. Once the install was completed I checked for any updates&#8230;<\/p>\n<pre style=\"text-align: justify;\">sudo aptitude update\r\nsudo aptitude safe-upgrade<\/pre>\n<p style=\"text-align: justify;\">First we install MySQL which will be the database engine used to store the catalog information.<\/p>\n<pre style=\"text-align: justify;\">sudo aptitude install mysql-client mysql-server<\/pre>\n<p style=\"text-align: justify;\">During the install you will be prompted for a password for the MySQL &#8220;root&#8221; user.<\/p>\n<p style=\"text-align: justify;\">Add SSH server to allow telnet remote access.<\/p>\n<pre style=\"text-align: justify;\">sudo aptitude install openssh-server<\/pre>\n<p style=\"text-align: justify;\">Next we install Apache web server which will be used by &#8220;BWeb&#8221; for remote administration (see later sections).<\/p>\n<pre style=\"text-align: justify;\">sudo aptitude install apache2<\/pre>\n<p style=\"text-align: justify;\">Last but not least&#8230; Bacula.<\/p>\n<pre style=\"text-align: justify;\">sudo aptitude install bacula<\/pre>\n<p style=\"text-align: justify;\">&#8220;Postfix&#8221; will be installed as one of the packages and you will be asked to select a configuration type. I just selected &#8220;<strong>Local only<\/strong>&#8221; and left the server name as the hostname of the machine. Next you will be asked to &#8220;<em>Configure database for bacula-director-mysql with dbconfig-common<\/em>&#8221; &#8211; select &#8220;<strong>Yes<\/strong>&#8221; then supply credentials for the database administrator followed by a new password for the bacula database user. The &#8220;database administrator&#8221; will need to have the appropriate rights to create a database.<\/p>\n<h2>Stage One: Configuring the Bacula server<\/h2>\n<p style=\"text-align: justify;\">Bacula configuration files are formatted based on resources comprising of directives surrounded by \u201c<strong>{}<\/strong>\u201d braces. Each Bacula component has an individual file in the <strong>\/etc\/bacula<\/strong> directory.<\/p>\n<p style=\"text-align: justify;\">The various Bacula components must authorize themselves to each other. This is accomplished using the password directive. For example, the Storage resource password in the <strong>\/etc\/bacula\/bacula-dir.conf<\/strong> file must match the Director resource password in <strong>\/etc\/bacula\/bacula-sd.conf<\/strong>.<\/p>\n<p style=\"text-align: justify;\">The Console can be used to query the Director about jobs, but to use the Console with a non-root user, the user needs to be in the bacula group. To add a user to the bacula group enter the following from a terminal:<\/p>\n<pre style=\"text-align: justify;\">sudo adduser <em><strong>username<\/strong> <\/em>bacula<\/pre>\n<p style=\"text-align: justify;\">Log out then back in to make the change effective. As mentioned in the previous section, I&#8217;m going to backup my data to local storage so I need to create a location for the &#8220;<strong>file media<\/strong>&#8220;. While we&#8217;re at it I&#8217;ll also create a directory where files can be restored to.<\/p>\n<pre style=\"text-align: justify;\">sudo mkdir -m 770 \/var\/lib\/archive\r\nsudo mkdir -m 770 \/var\/lib\/archive\/backup\r\nsudo mkdir -m 770 \/var\/lib\/archive\/restore sudo chown -R  bacula:bacula \/var\/lib\/archive<\/pre>\n<p style=\"text-align: justify;\">Everything in Bacula is about using IP addresses or resolvable addresses. But despite my hostnames being resolvable by DNS I still had to make sure there was an entry in the hosts file for this machine before it would work. If you&#8217;ve defined a static IP address, this will have been done automatically during the OS install.<\/p>\n<h3 style=\"text-align: justify;\">Configuring the File Daemon (bacula-fd.conf)<\/h3>\n<pre style=\"text-align: justify;\">sudo vi \/etc\/bacula\/bacula-fd.conf<\/pre>\n<p style=\"text-align: justify;\">In the <strong>FileDaemon<\/strong> {} block <span style=\"text-decoration: underline;\">change<\/span><\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #339966;\">FileDaemon {<\/span>\r\n\r\n<span style=\"color: #339966;\">    FDAddress = <em><strong>hostname.example.com<\/strong><\/em><\/span>\r\n<span style=\"color: #339966;\">\r\n}<\/span><\/pre>\n<p style=\"text-align: justify;\">Restart the bacula file daemon for the changes to take effect<\/p>\n<pre style=\"text-align: justify;\">sudo \/etc\/init.d\/bacula-fd restart<\/pre>\n<h3 style=\"text-align: justify;\">Configuring the Storage Daemon (bacula-sd.conf)<\/h3>\n<pre style=\"text-align: justify;\">sudo vi \/etc\/bacula\/bacula-sd.conf<\/pre>\n<p style=\"text-align: justify;\">In the <strong>Storage<\/strong> {} block <span style=\"text-decoration: underline;\">change<\/span><\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #339966;\">Storage {<\/span>\r\n\r\n<span style=\"color: #339966;\">    SDAddress = <em><strong>hostname.example.com<\/strong><\/em><\/span>\r\n\r\n<span style=\"color: #339966;\">}<\/span><\/pre>\n<p style=\"text-align: justify;\">In the <strong>Device<\/strong> {} block for &#8220;<strong>FileStorage<\/strong>&#8221; <span style=\"text-decoration: underline;\">change<\/span><\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #339966;\">Device {<\/span>\r\n<span style=\"color: #339966;\">    Name = <strong>FileStorage<\/strong><\/span>\r\n\r\n<span style=\"color: #339966;\">    Archive Device = <strong>\/var\/lib\/archive\/backup<\/strong><\/span>\r\n\r\n<span style=\"color: #339966;\">}<\/span><\/pre>\n<p style=\"text-align: justify;\">Restart the bacula storage daemon for the changes to take effect<\/p>\n<pre style=\"text-align: justify;\">sudo \/etc\/init.d\/bacula-sd restart<\/pre>\n<h3 style=\"text-align: justify;\">Configuring the Director (bacula-dir.conf)<\/h3>\n<pre style=\"text-align: justify;\">sudo vi \/etc\/bacula\/bacula-dir.conf<\/pre>\n<p style=\"text-align: justify;\">In the <strong>Director<\/strong> {} block <span style=\"text-decoration: underline;\">change<\/span><\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #339966;\">Director {<\/span>\r\n\r\n<span style=\"color: #339966;\">    DirAddress = <em><strong>hostname.example.com<\/strong><\/em><\/span>\r\n\r\n<span style=\"color: #339966;\">}<\/span><\/pre>\n<p style=\"text-align: justify;\">In the <strong>Client<\/strong> {} block <span style=\"text-decoration: underline;\">change<\/span><\/p>\n<pre style=\"text-align: justify;\">Client {\r\n    Name = <strong><em>hostname<\/em>-fd<\/strong>\r\n    Address = <em><strong>hostname.example.com<\/strong><\/em>\r\n\r\n}<\/pre>\n<p style=\"text-align: justify;\">In the <strong>Storage<\/strong> {} block <span style=\"text-decoration: underline;\">change<\/span><\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #339966;\">Storage {<\/span>\r\n\r\n<span style=\"color: #339966;\">    Address = <em><strong>hostname.example.com<\/strong><\/em><\/span>\r\n\r\n<span style=\"color: #339966;\">}<\/span><\/pre>\n<p style=\"text-align: justify;\">In the <strong>RestoreFiles<\/strong> \u00bb <strong>Job<\/strong> {} block <span style=\"text-decoration: underline;\">change<\/span><\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #339966;\">Job {<\/span>\r\n<span style=\"color: #339966;\">    Name = \"RestoreFiles\"<\/span>\r\n\r\n<span style=\"color: #339966;\">    Where = <strong>\/var\/lib\/archive\/restore<\/strong><\/span>\r\n<span style=\"color: #339966;\">}<\/span><\/pre>\n<p style=\"text-align: justify;\">In the <strong>Catalog<\/strong> {} block <span style=\"text-decoration: underline;\">add<\/span><\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #339966;\">Catalog {<\/span>\r\n<span style=\"color: #339966;\">    Name = MyCatalog<\/span>\r\n<span style=\"color: #339966;\">    dbname = <em><strong>bacula<\/strong><\/em>; DB Address = \"<em><strong>localhost<\/strong><\/em>\"; dbuser = \"<em><strong>bacula<\/strong><\/em>\"; dbpassword = \"<em><strong>baculaPASSWORD<\/strong><\/em>\"<\/span>\r\n<span style=\"color: #339966;\">}<\/span><\/pre>\n<p style=\"text-align: justify;\">I don&#8217;t think this is a &#8220;requirement&#8221; but I changed it for the sake of &#8220;consistancy&#8221; and &#8220;completeness&#8221;.<\/p>\n<p style=\"text-align: justify;\">Restart the bacula director for the changes to take effect<\/p>\n<pre style=\"text-align: justify;\">sudo \/etc\/init.d\/bacula-director restart<\/pre>\n<h3 style=\"text-align: justify;\">Using Bconsole<\/h3>\n<p style=\"text-align: justify;\">I have to create the media for the backup jobs to use now. For that we use bconsole<\/p>\n<pre style=\"text-align: justify;\">bconsole\r\n\r\n<span style=\"color: #0000ff;\">Connecting to Director <em><strong>hostname.example.com<\/strong><\/em>:9101<\/span>\r\n<span style=\"color: #0000ff;\">1000 OK: hostname-dir Version: 5.0.1 (24 February 2010)<\/span>\r\n<span style=\"color: #0000ff;\">Enter a period to cancel a command.<\/span>\r\n<span style=\"color: #0000ff;\">*<\/span><\/pre>\n<p style=\"text-align: justify;\">Automatically create the media and label it with the following command<\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #0000ff;\">* <strong>label\r\n<\/strong>Automatically selected Catalog: MyCatalog<\/span>\r\n<span style=\"color: #0000ff;\">Using Catalog \"MyCatalog\"<\/span>\r\n<span style=\"color: #0000ff;\">Automatically selected Storage: File<\/span>\r\n<span style=\"color: #0000ff;\">Enter new Volume name:<\/span><\/pre>\n<p style=\"text-align: justify;\">Enter a meaningfull name for this &#8220;<em>File<\/em>&#8221; based media. I call mine &#8220;<strong>File-Repository<\/strong><em>xxx<\/em>&#8221; where <em>xxx<\/em> increments 001,002,003&#8230; Select a relevant pool to make this media available in (I select &#8220;<strong>File<\/strong>&#8220;). If the permissions on our <strong>\/var\/lib\/archive\/<\/strong> directories and the storage daemon are configured correctly, you should see&#8230;<\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #0000ff;\">Connecting to Storage daemon File at hostname.example.com:9103 ...<\/span>\r\n<span style=\"color: #0000ff;\">Sending label command for Volume \"<strong>File-Repository001<\/strong>\" Slot 0 ...<\/span>\r\n<span style=\"color: #0000ff;\">3000 OK label. VolBytes=202 DVD=0 Volume=\"File-Repository001\" Device=\"<strong>FileStorage<\/strong>\" (\/var\/lib\/archive\/backup)<\/span>\r\n<span style=\"color: #0000ff;\">Catalog record for Volume \"<strong>File-Repository001<\/strong>\", Slot 0 successfully created.<\/span>\r\n<span style=\"color: #0000ff;\">Requesting to mount FileStorage ...<\/span>\r\n<span style=\"color: #0000ff;\">3906 File device \"<strong>FileStorage<\/strong>\" (<strong>\/var\/lib\/archive\/backup<\/strong>) is always mounted.<\/span><\/pre>\n<p style=\"text-align: justify;\">This has now created a volume that will store a maximum of 50GB, as defined in the <strong>Pool<\/strong> {} section for File in the <strong>bacula-dir.conf<\/strong><\/p>\n<p style=\"text-align: justify;\">You can check the status of the various components with the status command. To check the status of the director and defined jobs type<\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #0000ff;\">* <strong>status director<\/strong><\/span><\/pre>\n<p style=\"text-align: justify;\">If you&#8217;re unsure of a command, you can list them all by typing<\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #0000ff;\">* <strong>help<\/strong><\/span><\/pre>\n<p style=\"text-align: justify;\">For help on a specific command, type help followed by the <em>command<\/em> name i.e.<\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #0000ff;\">* <strong>help status<\/strong><\/span>\r\n<span style=\"color: #0000ff;\">* <strong>help list<\/strong><\/span><\/pre>\n<h2>Stage Two: Backup local files to local storage<\/h2>\n<p style=\"text-align: justify;\">In Bacula, the backup jobs are defined in the <strong>bacula-dir.conf<\/strong> file in the <strong>Job<\/strong> {} blocks. Normally (and for flexability) each job is defined with reference to a <strong>Fileset<\/strong> {}, <strong>Schedule<\/strong> {}, and <strong>Storage<\/strong> {} subset. Common elements can be included in the <strong>JobDefs<\/strong> {} subset and can be referenced in each job to avoid repitition and to save on scripting.<\/p>\n<p style=\"text-align: justify;\">We&#8217;ll create a simple job to backup the <em>\/etc<\/em> directory (including sub-directories) but ultimately it&#8217;s up to you how you&#8217;ll configure your jobs.<\/p>\n<pre style=\"text-align: justify;\">sudo vi \/etc\/bacula\/bacula-dir.conf<\/pre>\n<p style=\"text-align: justify;\">Check what is already defined for <strong>JobDefs<\/strong> {}. It shoudl look something like this:<\/p>\n<pre><span style=\"color: #339966;\">JobDefs {\r\n  Name = \"<em><strong>DefaultJob<\/strong><\/em>\"\r\n  Type = Backup\r\n  Level = Incremental\r\n  Client = <strong><em>hostname<\/em><\/strong>-fd\r\n  FileSet = \"Full Set\"\r\n  Schedule = \"WeeklyCycle\"\r\n  Storage = File\r\n  Messages = Standard\r\n  Pool = File\r\n  Priority = 10\r\n  Write Bootstrap = \"\/var\/lib\/bacula\/%c.bsr\"\r\n}<\/span><\/pre>\n<blockquote>\n<p style=\"text-align: justify;\"><strong><span style=\"color: #ff6600;\">NOTE:<\/span><\/strong><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #ff6600;\">Any entries duplicated in the <strong>Job<\/strong> { } section, take precedence over ones already defined in the <strong>JobDefs<\/strong> { } section.<\/span><\/p>\n<\/blockquote>\n<p style=\"text-align: justify;\">Next step is to create a new backup job entry.<\/p>\n<pre><span style=\"color: #339966;\">Job {\r\n  Name = \"LocalConfigBackup\"\r\n  JobDefs = \"<strong>DefaultJob<\/strong>\"\r\n  Type = Backup\r\n  Level = Full\r\n  Storage = File\r\n  Client = <strong><em>hostname<\/em><\/strong>-fd\r\n  FileSet = \"LocalConfigFiles\"\r\n  Schedule = \"DailyBackup\"\r\n}<\/span><\/pre>\n<p style=\"text-align: justify;\">Notes on the <strong>Job<\/strong> {} definition:<\/p>\n<ul>\n<li><em>Name<\/em> &#8211; defines the name of this particular job.<\/li>\n<li><em>JobDefs<\/em> &#8211; tells the job to load a particular set of default definitions called &#8220;<em>DefaultJob<\/em>&#8220;.<\/li>\n<li><em>Type<\/em> &#8211; tells the director it is a backup job.<\/li>\n<li><em>Level<\/em> &#8211; tells the director it should back *<span style=\"text-decoration: underline;\">everything<\/span>* up, not just files that have changed.<\/li>\n<li><em>Storage<\/em> &#8211; tells the director to use the storage defined in the <strong>Storage<\/strong> {} section as &#8220;<strong>File<\/strong>&#8221; (this in turn is referenced in the <strong>bacula-sd.conf<\/strong> file &#8211; in our case the local storage daemon)<\/li>\n<li><em>Client<\/em> &#8211; tells the director to use the client defined as &#8220;<em>hostname<\/em>-fd&#8221;, which in our case is the local machine (or more specifically, the local file daemon).<\/li>\n<li><em>FileSet<\/em> &#8211; tells the director to backup the files defined in the <strong>FileSet<\/strong> {} section named &#8220;<em>LocalConfigFiles<\/em>&#8220;.<\/li>\n<li><em>Schedule<\/em> &#8211; tells the director when to backup the files using values defined in the <strong>Schedule<\/strong> {} section named &#8220;<strong>DailyBackup<\/strong>&#8220;.<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">Now we can create a <strong>FileSet<\/strong> {} (referenced in the <strong>Job<\/strong> {} above). Filesets are handy and can be used by multiple jobs. An example might be backing up the same files, but off multiple different clients.<\/p>\n<pre><span style=\"color: #339966;\">FileSet {\r\n  Name = \"<strong>LocalConfigFiles<\/strong>\"\r\n  Include {\r\n    Options {\r\n      signature = MD5\r\n      compression=GZIP\r\n    }\r\n    File = <strong>\/etc<\/strong>\r\n  }\r\n}<\/span><\/pre>\n<p style=\"text-align: justify;\">This FileSet will backup the <strong>\/etc<\/strong> directory. The <em>Options<\/em> resource directives configure the <em>FileSet<\/em> to create a <em>MD5<\/em> signature for each file backed up, and to compress the files using <em>GZIP<\/em>.<\/p>\n<p style=\"text-align: justify;\">Next, create a new Schedule for the backup job:<\/p>\n<pre><span style=\"color: #339966;\">Schedule {\r\n  Name = \"DailyBackup\"\r\n  Run = Full daily at 06:00\r\n}<\/span><\/pre>\n<p style=\"text-align: justify;\">The job will run every day at <em>06:00<\/em> or <em>6:00 am<\/em>. There are many other scheduling options available. Now lets run bconsole<\/p>\n<pre style=\"text-align: justify;\">bconsole\r\n\r\n<span style=\"color: #0000ff;\">* <strong>run<\/strong><\/span><\/pre>\n<p style=\"text-align: justify;\">The select the number that corresponds to the job you just created. When prompted with &#8220;<em>OK to run?<\/em>&#8221; answer <strong>Y<\/strong> and press enter. You should then see&#8230;<\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #0000ff;\">Job queued. JobId=2<\/span>\r\n<span style=\"color: #0000ff;\">*<\/span><\/pre>\n<p style=\"text-align: justify;\">It shouldn&#8217;t take very long for this job to complete (a few seconds depending on the speed of your machine). If you check the status of the director you should then see your job, with the <em>JobId <\/em>in the <em>Terminated jobs:<\/em> section<\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #0000ff;\">* <strong>status director<\/strong><\/span>\r\n<span style=\"color: #0000ff;\">hostname-dir Version: 5.0.1 (24 February 2010) x86_64-pc-linux-gnu ubuntu 10.04<\/span>\r\n\r\n<span style=\"color: #0000ff;\">Terminated Jobs:<\/span>\r\n<span style=\"color: #0000ff;\">JobId Level Files Bytes Status Finished Name<\/span>\r\n<span style=\"color: #0000ff;\">====================================================================<\/span>\r\n<span style=\"color: #0000ff;\">2 Full 1,284 590.0 K OK 04-Nov-10 13:40 <strong>LocalConfigBackup<\/strong><\/span><\/pre>\n<p style=\"text-align: justify;\">Congratulations! You have successfully used Bacula to backup files locally!! Now move onto the next section to backup files across the network.<\/p>\n<h2>Stage Three: Backup remote files to local storage.<\/h2>\n<p style=\"text-align: justify;\">Probably one of the most helpfull images in the Bacula documentation was this one, included below. It was really handy in helping to understand the relationship between the various components, particularly the remote ones!<a href=\"http:\/\/www.templesoft.co.nz\/journal\/wp-content\/uploads\/2010\/11\/bacula-relationship_transparent-428x510.png\"><img loading=\"lazy\" decoding=\"async\" width=\"428\" height=\"510\" class=\"wp-image-70 aligncenter\" src=\"http:\/\/www.templesoft.co.nz\/journal\/wp-content\/uploads\/2010\/11\/bacula-relationship_transparent-428x510.png\" alt=\"Bacula Relationship\" \/><\/a><\/p>\n<h3 style=\"text-align: justify;\">The File-Daemon on the remote machine<\/h3>\n<p style=\"text-align: justify;\">Because of the various &#8220;distros&#8221; I&#8217;ll assume at this point that you&#8217;ve installed the <strong>bacula-fd<\/strong> daemon on the client you intend to backup. Start by opening up the <strong>bacula-fd.conf<\/strong> file on the remote machine and make a few changes.<\/p>\n<pre>sudo vi \/etc\/bacula\/bacula-fd.conf\r\n\r\n<span style=\"color: #339966;\">Director {\r\n  Name = <strong><em>hostname<\/em><\/strong>-dir   # this is the name of the director\r\n  Password = \"<strong><span style=\"color: #ff0000;\"><em>aUniquePASSWORDofYourChoiceforFD<\/em><\/span><\/strong>\"\r\n}<\/span>\r\n\r\n<span style=\"color: #339966;\"> \r\nFileDaemon {                          \r\n  Name = <strong><em>FDName<\/em><\/strong>-fd\r\n  FDport = 9102    \r\n  WorkingDirectory = \/var\/lib\/bacula\r\n  Pid Directory = \/var\/run\/bacula\r\n  Maximum Concurrent Jobs = 20\r\n  FDAddress = <em><strong>FDName.example.com<\/strong><\/em>\r\n}<\/span><\/pre>\n<p style=\"text-align: justify;\">Restart the daemon for the changes to become effective. In some cases it may not be started already and you may even need to edit init scripts to ensure it starts on boot (CentOS and FreeBSD I&#8217;m looking at you!)<\/p>\n<pre style=\"text-align: justify;\">sudo \/etc\/init.d\/bacula-fd restart<\/pre>\n<p style=\"text-align: justify;\">Now head back over to the machine running the director and edit&#8230;<\/p>\n<pre style=\"text-align: justify;\">sudo vi \/etc\/bacula\/bacula-dir.conf<\/pre>\n<p style=\"text-align: justify;\">\u00a0and add an entry for the client you&#8217;ve just created.<\/p>\n<pre><span style=\"color: #339966;\">Client {\r\n  Name = <strong><em>FDName<\/em><\/strong>-fd\r\n  Address = <em><strong>FDName.example.com<\/strong><\/em>\r\n  FDPort = 9102\r\n  Catalog = MyCatalog\r\n  Password = \"<span style=\"color: #ff0000;\"><strong><em>aUniquePASSWORDofYourChoiceforFD<\/em><\/strong><\/span>\"\r\n  File Retention = 30 days\r\n  Job Retention = 6 months\r\n  AutoPrune = yes\r\n}<\/span><\/pre>\n<p style=\"text-align: justify;\">You can also create a Job, Fileset and Schedule as detailed in the previous section and then restart the director for the changes to take effect.<\/p>\n<pre style=\"text-align: justify;\">sudo \/etc\/init.d\/bacula-director restart<\/pre>\n<blockquote>\n<p style=\"text-align: justify;\"><span style=\"color: #ff6600;\"><strong>NOTE:<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #ff6600;\">Be aware of firewalls running on any machines that run the client, as they may block traffic and stop communication between the Director and FileDaemon.<\/span><\/p>\n<\/blockquote>\n<p style=\"text-align: justify;\">You can check communication between the Director and FileDaemon using bconsole<\/p>\n<pre style=\"text-align: justify;\">bconsole\r\n\r\n<span style=\"color: #0000ff;\">* <strong>status client\r\n<\/strong><\/span><\/pre>\n<p style=\"text-align: justify;\">then select the appropriate client from the list. If you&#8217;ve created a Job, Fileset etc&#8230; you can perform an estimate on the backup Job&#8230;<\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #0000ff;\">* <strong>estimate<\/strong><\/span><\/pre>\n<p style=\"text-align: justify;\">then select the appropriate remote job from the list. You should get a response similar to&#8230;<\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #0000ff;\">2000 OK estimate files=2678 bytes=109,647,535<\/span><\/pre>\n<h3 style=\"text-align: justify;\">Notes on installing bacula-fd on CentOS 5<\/h3>\n<p style=\"text-align: justify;\">My VoIP server uses CentOS as its Linux distro, and it would be handy to back the config files and voicemail messages. By default, none of the YUM repositories (package manager for CentOS) have a copy of bacula, so you have to add one that does&#8230; <strong>EPEL<\/strong>. There was reference online to <strong>RPMForge<\/strong>, but once installed I couldn&#8217;t find a copy of bacula on it. <a href=\"http:\/\/www.question-defense.com\/2010\/04\/22\/install-the-epel-repository-on-centos-linux-5-x-epel-repo\">This site<\/a> has a great post on how to enable the EPEL repository, otherwise&#8230;<\/p>\n<pre style=\"text-align: justify;\">rpm -Uvh http:\/\/<strong>download.fedora.redhat.com<\/strong>\/pub\/epel\/5\/i386\/epel-release-5-4.noarch.rpm<\/pre>\n<p style=\"text-align: justify;\">will create the relevant repository entries in <strong>\/etc\/yum.repos.d\/<\/strong>. Then download and install the bacula-client&#8230;<\/p>\n<pre style=\"text-align: justify;\">yum install bacula-client<\/pre>\n<p style=\"text-align: justify;\">All you have to do is configure the FileDaemon as detailed above. I used <em>chkconfig<\/em> to get it to start at boot.<\/p>\n<pre style=\"text-align: justify;\">chkconfig --level 345 bacula-fd on<\/pre>\n<h2 style=\"text-align: justify;\">Stage Four: Backup remote (or local) files to remote storage<\/h2>\n<h3 style=\"text-align: justify;\">Notes on installing bacula-sd on FreeBSD 7.1<\/h3>\n<p>To install the storage daemon add the repository&#8230;<\/p>\n<pre style=\"text-align: justify;\">setenv PACKAGESITE ftp:\/\/ftp.freebsd.org\/pub\/FreeBSD\/ports\/i386\/packages-7-stable\/Latest\/ pkg_add -r bacula-server\r\n\r\ncd \/usr\/local\/lib\r\nln -s libintl.so.8 libintl.so.9\r\ncp bacula-sd.conf.sample bacula-sd.conf\r\nvi bacula-sd.conf<\/pre>\n<p style=\"text-align: justify;\">Start the storage daemon service<\/p>\n<pre style=\"text-align: justify;\">\/usr\/local\/sbin\/bacula-sd -c \/usr\/local\/etc\/bacula-sd.conf<\/pre>\n<p style=\"text-align: justify;\">Because this server is actually running FreeNAS server, use the web interface to add the above command into the <strong>System<\/strong>|<strong>Advanced<\/strong>|<strong>Command<\/strong> <strong>scripts<\/strong> section.<\/p>\n<h2>\u00a0Installing Bweb<\/h2>\n<p style=\"text-align: justify;\">Bweb is a perl based web program that provides a tool to perform basic operations and to get statistics. It obtains its information from your catalog database and the bconsole program. In this section the assumption is that you already have a working Bacula server, Apache server and MySQL.<\/p>\n<p style=\"text-align: justify;\">First, we install some pre-requisite libraries.<\/p>\n<pre style=\"text-align: justify;\">sudo apt-get install -y libgdchart-gd2-xpm* make php-pear preload\r\nsudo apt-get install -y libgd-graph-perl libhtml-template-perl libexpect-perl\r\nsudo apt-get install -y libdbd-mysql-perl libdbd-pg-perl libdbi-perl libtime-modules-perl\r\nsudo apt-get install -y libdate-calc-perl\r\nsudo pear install db<\/pre>\n<p style=\"text-align: justify;\">You may get a warning at this stage that &#8220;<em>DB<\/em>&#8221; is depreciated in favour of &#8220;<em>MDB2<\/em>&#8220;. Since <em>MDB2<\/em> is newer it&#8217;s probably better, but <em>DB<\/em> works fine for me &#8211; as part of the cleanup, if I find there is a major difference, I&#8217;ll note it here and alter my notes.<\/p>\n<p style=\"text-align: justify;\">Now we download the bweb which is in the latest Bacula package. At the time of writing this, the latest version was <strong>5.0.3<\/strong>, but you can check <a href=\"http:\/\/sourceforge.net\/projects\/bacula\/files\/bacula\">here<\/a> and alter the instructions as required.<\/p>\n<pre style=\"text-align: justify;\">wget http:\/\/sourceforge.net\/projects\/bacula\/files\/bacula\/5.0.3\/bacula-gui-5.0.3.tar.gz<\/pre>\n<p style=\"text-align: justify;\">Now extract the files, compile the source and install some of the files to thier relevant locations<\/p>\n<pre style=\"text-align: justify;\">tar -zxvf bacula-gui-5.0.3.tar.gz\r\ncd bacula-gui-5.0.3\/bweb\r\nsudo perl Makefile.PL\r\nsudo make install\r\nsudo pear channel-update pear.php.net\r\nsudo mkdir -m 755 \/usr\/lib\/cgi-bin\/bweb\r\nsudo install -m 755 -o root -g root cgi\/*.pl \/usr\/lib\/cgi-bin\/bweb<\/pre>\n<p style=\"text-align: justify;\">Next, some authority changes, template copying and installing the HTML files<\/p>\n<pre style=\"text-align: justify;\">sudo chown root:bacula \/etc\/bacula\r\nsudo vi \/etc\/bacula\/bweb.conf\r\n\r\n<span style=\"color: #339966;\">    $VAR1 = { template_dir =&gt; \"\/usr\/share\/bweb\/tpl\" };<\/span>\r\n\r\nsudo chown root:www-data \/etc\/bacula\/bweb.conf\r\nsudo mkdir -p \/usr\/share\/bweb\/tpl\/en\r\nsudo install -m 644 -o root -g root bweb\/lang\/en\/tpl\/*.tpl \/usr\/share\/bweb\/tpl\/en\r\n\r\nsudo mkdir \/var\/www\/bweb\r\nsudo install -m 644 -o root -g root bweb\/html\/*.{js,png,css,gif,ico,html} \/var\/www\/bweb\r\n\r\nsudo chmod 666 \/etc\/bacula\/bconsole.conf<\/pre>\n<p style=\"text-align: justify;\">The <a href=\"http:\/\/www.sencha.com\/products\/js\/\">Ext JS<\/a> JavaScript library is needed for the &#8220;<em>Web Restore<\/em>&#8221; functionality to work properly. It&#8217;s probably writtern somewhere, but it didn&#8217;t leap out at me&#8230; it was <a href=\"http:\/\/getfirebug.com\/\">Firebug<\/a> that helped me to discover what was missing. The latest version at the time of publication was 3.3.0. First (in case you don&#8217;t have it already) install <strong>unzip<\/strong>.<\/p>\n<pre style=\"text-align: justify;\">sudo aptitide install -y unzip<\/pre>\n<p style=\"text-align: justify;\">Then we get the Ext JS package from the Ext JS CDN.<\/p>\n<pre style=\"text-align: justify;\">sudo wget http:\/\/extjs.cachefly.net\/ext-3.3.0.zip<\/pre>\n<p style=\"text-align: justify;\">Then install the files in the bweb folder<\/p>\n<pre style=\"text-align: justify;\">sudo unzip ext-3.3.0.zip\r\nsudo mkdir -m 755 \/var\/www\/bweb\/ext\r\nsudo cp -r ext-3.3.0\/. \/var\/www\/bweb\/ext<\/pre>\n<p style=\"text-align: justify;\">A few more changes to enable the web restore functionality of bweb&#8230;<\/p>\n<pre>sudo vi \/etc\/apache2\/httpd.conf\r\n\r\n<span style=\"color: #339966;\">    Alias \/bweb\/fv \/var\/spool\/bweb<\/span>\r\n<span style=\"color: #339966;\">    &lt;Directory \"\/var\/spool\/bweb\"&gt;<\/span>\r\n<span style=\"color: #339966;\">        Options None<\/span>\r\n<span style=\"color: #339966;\">        AllowOverride AuthConfig<\/span>\r\n<span style=\"color: #339966;\">        Order allow,deny<\/span>\r\n<span style=\"color: #339966;\">        Allow from all<\/span>\r\n<span style=\"color: #339966;\">    &lt;\/Directory&gt;<\/span>\r\n\r\nsudo mkdir \/var\/spool\/bweb\r\nsudo chmod 700 \/var\/spool\/bweb\r\nsudo chown www-data \/var\/spool\/bweb<\/pre>\n<p style=\"text-align: justify;\">then there are a number of changes to the database structure to support bweb that need to be made. You can import the commands from the <strong>bweb-mysql.sql<\/strong> file located in <strong>bacula-gui-5.0.3\/bweb\/script<\/strong>, but because I wasn&#8217;t sure of the results I just &#8220;cut-and-pasted&#8221; section by section using multiple SSH sessions, one running MySQL the other with the <strong>bacula-gui-5.0.3\/bweb\/script\/bweb-mysql.sql<\/strong> file open, checking the results after each command.<\/p>\n<p style=\"text-align: justify;\">To import it directly into the bacula database use<\/p>\n<pre style=\"text-align: justify;\">mysql -u root -p bacula\r\n\r\n<span style=\"color: #0000ff;\">mysql&gt;<strong> SOURCE<\/strong> <span style=\"color: #99ccff;\"><em>path to files<\/em><\/span>\/bacula-gui-5.0.3\/bweb\/script\/<strong>bweb-mysql.sql<\/strong>;<\/span><\/pre>\n<p style=\"text-align: justify;\">Next we must give the <strong>www-data<\/strong> (apache) user permission to execute the bconsole.<\/p>\n<blockquote>\n<p style=\"text-align: justify;\"><strong><span style=\"color: #ff6600;\">NOTE:<\/span><\/strong><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #ff6600;\">The locations highlighted in <span style=\"color: #ff0000;\">red<\/span> below may differ on other Linux distributions&#8230; BE AWARE &#8211; and substitute as required!<\/span><\/p>\n<\/blockquote>\n<pre style=\"text-align: justify;\">cd \/etc\r\nsudo visudo<\/pre>\n<p style=\"text-align: justify;\">After the line <strong>root ALL=(ALL) ALL <\/strong>we add this&#8230;<\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #339966;\">www-data ALL= NOPASSWD: <span style=\"color: #ff0000;\">\/usr\/sbin\/bacula-console<\/span><\/span>\r\n<span style=\"color: #339966;\">www-data ALL = (root) NOPASSWD: \/usr\/sbin\/mtx -f \/dev\/changer transfer *<\/span>\r\n<span style=\"color: #339966;\">www-data ALL = (root) NOPASSWD: \/usr\/sbin\/mtx -f \/dev\/changer status<\/span>\r\n<span style=\"color: #339966;\">www-data ALL = (root) NOPASSWD: \/usr\/sbin\/mtx -f \/dev\/changer load *<\/span>\r\n<span style=\"color: #339966;\">www-data ALL = (root) NOPASSWD: \/usr\/sbin\/mtx -f \/dev\/changer unload *<\/span><\/pre>\n<p style=\"text-align: justify;\">You then <strong>Ctrl-X<\/strong> to exit, then when it warns you that the buffers have changed, answer &#8220;<strong>Y<\/strong>&#8221; and then change the file name from <strong>sudoers.tmp<\/strong> to <strong>sudoers<\/strong>. Answer &#8220;<strong>Y<\/strong>&#8221; to overwrite.<\/p>\n<p style=\"text-align: justify;\">Now we go back to the <strong>bweb.conf<\/strong> file to make some final changes<\/p>\n<pre>sudo vi \/etc\/bacula\/bweb.conf\r\n<span style=\"color: #339966;\">\r\n$VAR1 = bless( {\r\n  'graph_font' =&gt; '\/usr\/share\/fonts\/truetype\/ttf-bitstream-vera\/Vera.ttf',\r\n  'name' =&gt; undef,\r\n  'config_file' =&gt; '<strong><em>\/etc\/bacula\/bweb.conf<\/em><\/strong>',\r\n  'bconsole' =&gt; '\/<strong><span style=\"color: #ff0000;\">usr\/sbin\/bacula-console<\/span><\/strong> -n -c \/etc\/bacula\/bconsole.conf',\r\n  'ach_list' =&gt; {\r\n     'S1_L80' =&gt; bless( {\r\n         'info' =&gt; {\r\n                     'drive' =&gt; 0,\r\n                     'io' =&gt; 0,\r\n                     'slot' =&gt; 0\r\n                   },\r\n         'name' =&gt; 'S1_L80',\r\n         'bweb' =&gt; undef,\r\n         'device' =&gt; '\/dev\/changer',\r\n         'drive' =&gt; [],\r\n         'debug' =&gt; 0,\r\n         'label' =&gt; {},\r\n         'precmd' =&gt; 'sudo',\r\n         'io' =&gt; [],\r\n         'mtxcmd' =&gt; '\/usr\/sbin\/mtx',\r\n         'drive_name' =&gt; [\r\n                           'S1_L80_SDLT0',\r\n                           'S1_L80_SDLT1'\r\n                         ],\r\n         'slot' =&gt; []\r\n       }, 'Bweb::Autochanger' )\r\n   },\r\n  'dbi' =&gt; '<strong>DBI:mysql:database=bacula<\/strong>',\r\n  'user' =&gt; '<strong>bacula<\/strong>',\r\n  'password' =&gt; '<strong><em>baculaPASSWORD<\/em><\/strong>',\r\n  'fv_write_path' =&gt; '<strong><em>\/var\/spool\/bweb<\/em><\/strong>',\r\n  'template_dir' =&gt; '\/usr\/share\/bweb\/tpl',\r\n  'lang' =&gt; 'en',\r\n  'error' =&gt; '',\r\n  'debug' =&gt; 0,\r\n  'email_media' =&gt; '<strong><em>someone@hostname.example.com<\/em><\/strong>'\r\n}, 'Bweb::Config' );<\/span><\/pre>\n<p style=\"text-align: justify;\">Last of all, restart the server for the changes to take effect&#8230;<\/p>\n<pre style=\"text-align: justify;\">sudo shutdown -r now<\/pre>\n<p style=\"text-align: justify;\">If everything has been configured properly, you should be able to start your web browser and go to <strong>http:\/\/hostname.example.com\/bweb<\/strong> and see the bweb interface with information on your backup jobs, media, etc..<\/p>\n<blockquote>\n<p style=\"text-align: justify;\"><strong><span style=\"color: #ff6600;\">IMPORTANT NOTE:<\/span><\/strong><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #ff6600;\">While BWEB was tested &#8211; and worked &#8211; with both IE (8) and Firefox (3.6.13), the &#8220;Web Restore&#8221; component only seemed to function with Firefox. When selected from IE nothing seemed to happen, and no data displayed within the browser window. Since Firefox is my browser of choice I hadn&#8217;t put too much effort into investigating why this is, and did&#8230; well&#8230; nothing! If I do find out, or happen upon a reason I&#8217;ll note my findings here.<\/span><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: justify;\"><strong><span style=\"color: #ff6600;\">MILESTONE 24\/12\/2010:<\/span><\/strong><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #ff6600;\">I had a user delete all the messages from their &#8220;Sent&#8221; folder and I had to use BWEB to do a restore &#8211; It was SO COOL! I had some trepidation over how the restore would work thinking that the Bacula File Daemon would only allow one-way traffic and I would have to restore to a local destination and copy the files to their original location (and all the file permission changes that would ensue).<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #ff6600;\">BUT&#8230; Bacula (specifically via BWEB&#8217;s &#8220;Web Restore&#8221; function) allowed a restore to the original location with prompting to overwrite if required!! HOORAY!! I love you Bacula, you&#8217;ve made my Christmas&#8230;<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>I hate tape! Ever since those early days working as an operator, my least favourite job was changing the daily backup tape. Oh sure, if your company has loads of cash you could shell out for an autochanger, but none of the organisations I worked for were ever prepared to pony up the dosh for&#8230;  <a class=\"excerpt-read-more\" href=\"https:\/\/templesoft.co.nz\/journal\/?p=62\" title=\"Read Using Bacula to archive data.\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[52,56,55,53,54,58,57],"class_list":["post-62","post","type-post","status-publish","format-standard","hentry","category-technical-resource","tag-bacula","tag-bacula-fd","tag-bacula-sd","tag-bweb","tag-director","tag-fileset","tag-schedule"],"_links":{"self":[{"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=\/wp\/v2\/posts\/62","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=62"}],"version-history":[{"count":12,"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":189,"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions\/189"}],"wp:attachment":[{"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}