Pages

Friday, January 27, 2012

Creating a new bacula job

This time I want you to show how to create a new job within bacula to backup your files. In this article I will setup a job to backup /etc from my master server which is very easy. To do this go into the bacula configuration directory and edit the jobs resource file to add the new job: 

# cd /opt/bacula/latest/etc
# vi common/jobs.conf
...
Job {
  Name = "bck01_etc"
  Type = Backup
  Client = bck01-fd
  Schedule = "etc"
  Storage = DDS-3-01
  Pool = etc
  Messages = Standard
  Priority = 10
  Level = Full
  FileSet="etc"
  Write Bootstrap = "/local/bacula_bootstrap/%c.%n.bsr"

}
...

The file above is pretty easy. It contains a name directive (bck01_etc), client (bck01) and explains where to store the files (DDS-3-01). Two other important directives I use here is the schedule and the fileset. First take a look at my defined schedule:

# vi common/schedule.conf
...
Schedule {
  Name = "etc"
  Run = Full 1st sun at 04:00
  Run = Incremental mon-sat at 04:00
}
...

The schedule above will perform a full backup every sunday at 04:00 AM and incremental backup from monday till saturday at 04:00 AM. Then edit the fileset:

# vi common/fileset.conf
...
FileSet {
  Name = "etc"
  Include {
    Options {
      signature = MD5
    }
    File = "/etc"
  }
  Exclude {
    File = /etc/svc/volatile
  }
}
...

The above fileset defines to backup /etc except for /etc/svc/volatile (which is a seperate filesystem in Solaris). After creating a new job, a new schedule and a new fileset you have to restart the bacula director:

# kill -15 `pgrep bacula-dir`
# /opt/bacula/latest/sbin/bacula-dir -c /opt/bacula/latest/etc/bacula-dir.conf

Then run the job to see if it works. First start bconsole:

# bconsole
Connecting to Director bck01:9101
1000 OK: bck01-dir Version: 5.2.3 (16 December 2011)
Enter a period to cancel a command.

Then use the run command to start the new job:

*run
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
A job name must be specified.
The defined Job resources are:
     1: BackupCatalog
     2: bck01_etc
     3: RestoreFiles
Select Job resource (1-3): 2
Run Backup job
JobName:  bck01_etc
Level:    Full
Client:   bck01-fd
FileSet:  etc
Pool:     etc (From Job resource)
Storage:  DDS-3-01 (From Job resource)
When:     2012-01-27 20:15:31
Priority: 10
OK to run? (yes/mod/no): y
Job queued. JobId=17

As you can see all prior defined options will be used and the job will be started. Take a look at the messages or mails to see if the job works.

No comments:

Post a Comment