Pages

Sunday, February 12, 2012

Migration with bacula

Imagine you have the following situation: two database servers each with a large database. To backup each database you need 12 hours but you only have one tape drive. How to backup both databases to one tape drive without running the backup at daytime? As the topic says it: using bacula migration. When using migration you can start both backups at eg. 20:00, one backup writes directly to the single tape drive, the other backup to a disk storage. In this case both backups are accomplished between 20:00 and 08:00 the next day.
To copy the backup from the disk storage to the tape you need to define a migration job. This migration job will then copy the database backup from the disk to the tape again (this feature is known as 'Staging' from NetBackup or the 'Archiver' from Simpana). For the begining I will use the etc jobs which I have defined in prior articles in this blog. First take a look at the jobs:

# vi common/jobs.conf
...
Job {
  Name = "bck01_etc"
  Type = Backup
  Client = bck01-fd
  Schedule = "etc"
  Storage = D240-Tape
  Pool = D240-Tape
  Messages = Standard
  Priority = 10
  Level = Full
  FileSet="etc"
}

Job {
  Name = "dc01_etc"
  Type = Backup
  Client = dc01-fd
  Schedule = "etc"
  Storage = D240-File
  Pool = D240-File
  Messages = Standard
  Priority = 10
  Level = Full
  FileSet="etc"
}
...

The above example shows two jobs for backing up the /etc directories for two clients. One job write directly to tape (D240-Tape) and the other job writes to a disk storage (D240-File). Both jobs are using the same schedule:

# vi schedule.conf
...
Schedule {
  Name = "etc"
  Run = Full daily at 11:00
}
...

This means that both jobs will perform a full backup at 11:00 in the morning daily. No surprises so far. Now take a look at the pool resources:

# vi pool.conf
...
Pool {
  Name = D240-File
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Volume Retention = 14 days
  Maximum Volume Bytes = 10G
  Maximum Volumes = 6
  Storage = D240-File
  Next Pool = D240-Tape
}

Pool {
  Name = D240-Tape
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Volume Retention = 14 days
  Maximum Volume Bytes = 24G
  Maximum Volumes = 10
  Storage = D240-Tape
}
...

There is finally a little difference: the pool D240-File has the 'Next Pool' option set in the last line. This is needed to define a migration job which will migrate the data from disk storage to tape. Next is a new job, the migration itself:

# vi jobs.conf
...
Job {
  Name = "dc01_migrate"
  Type = Migrate
  Level = Full
  Client = bck01-fd
  Schedule = "migrate_dc01"
  FileSet = "etc"
  Pool = D240-File
  Messages = Standard
  Maximum Concurrent Jobs = 1
  Selection Type = Job
  Selection Pattern = "dc01_etc"
}
...

The above example has the 'Type' option 'Migrate' set (not 'Backup' as usual). It has it's own schedule defined and two other options: 'Selection Type' and 'Selection Pattern'. The selection type can be a job or a file. The selection pattern defines the name of what you want to migrate (You can use regex inside the selection pattern for multiple jobs/files).
At least the schedule for the migration job:

# vi schedula.conf
...
Schedule {
  Name = "migrate_dc01"
  Run = Full daily at 11:15
}
...

To backup the etc directory doesn't take a long time so I will start the migration of the dc01_etc job 15 minutes later.
With this setup you should even be able to backup two large database to a single tape drive in time.