![]()
Automatic Volume RecyclingNormally, Bacula will write on a volume, and once the tape is written, it may append to the volume, but it will never overwrite the data thus destroying it. When we speak of recycling volumes, we mean that Bacula can write over the previous contents of a volume. Thus all previous data will be lost.If you are like me, you may not want Bacula to automatically recycle (reuse) tapes. This requires a large number of tapes, and when I need a tape, I manually recycle it. For more on manual recycling, see the section entitled Manually Recycling Volumes below in this chapter. Most people prefer to have a Pool of tapes that are used for daily backups and recycled once a week, another Pool of tapes that are used for Full backups once a week and recycled monthly, and finally a Pool of tapes that are used once a month and recycled after a year or two. With a scheme like this, your pool of tapes remains constant. By properly defining your Volume Pools with appropriate Retention periods, Bacula can manage the recycling (such as defined above) automatically. Automatic recycling of Volumes is controlled by three
records in the Pool resource definition in the Director's
configuration file. These three records are:
A key point mentioned above that can be a source of frustration is that
Bacula will only recycle purged Volumes if there is no other appendable
Volume available. So, if you wish to "force" Bacula to use
a purged Volume, you must first ensure that no other Volume in the
Pool is marked Append. If necessary, you can manually set a volume
to Full. The reason for this is that Bacula wants to preserve the
data on your old tapes (even though purged from the catalog) as long
as absolutely possible before overwriting it.
Recycling AlgorithmAfter all Volumes of a Pool have been pruned (as mentioned above, this happens when a Job needs a new Volume and no appendable Volumes are available), Bacula will look for the oldest Volume that is Purged (all Jobs and Files expired), and if the Recycle flag is on (Recycle=yes) for that Volume, Bacula will relabel it and write new data on it.The full recycling algorithm that Bacula uses when it needs a new Volume is:
On the other hand, if you have inserted a different Volume after the last job, and Bacula recognizes the Volume as valid, it will request authorization from the Director to use this Volume. In this case, if you have set Recycle Current Volume = yes and the Volume is marked as Used or Full, Bacula will prune the volume and if all jobs were removed during the pruning (respecting the retention periods), the Volume will be recycled and used. For this to work, you must have Accept Any Volume = yes in the Pool. The recycling algorithm in this case is:
This permits users to manually change the Volume every day and load tapes in an order different from what is in the catalog, and if the volume does not contain a current copy of your backup data, it will be used. Recycle StatusEach Volume inherits the Recycle status (yes or no) from the Pool resource record when the Media record is created (normally when the Volume is labeled). This Recycle status is stored in the Media record of the Catalog. Using the the Console program, you may subsequently change the Recycle status for each Volume. For example in the following output from list volumes:+------------+-----------+-----------+----------+------------------+----------+-------+ | VolumeName | MediaType | VolStatus | VolBytes | LastWritten | VolReten | Recyc | +------------+-----------+-----------+----------+------------------+----------+-------+ | File0001 | File | Full | 4190055 | 2002-05-25 18:42 | 14400 | 1 | | File0002 | File | Full | 1896460 | 2002-05-26 18:05 | 14400 | 1 | | File0003 | File | Full | 1896460 | 2002-05-26 20:05 | 14400 | 1 | | File0004 | File | Full | 1896460 | 2002-05-26 21:35 | 14400 | 1 | | File0005 | File | Full | 1896460 | 2002-05-26 22:05 | 14400 | 1 | | File0006 | File | Full | 1896460 | 2002-05-26 19:35 | 14400 | 1 | | File0007 | File | Purged | 1896466 | 2002-05-26 18:05 | 14400 | 1 | +------------+-----------+-----------+----------+------------------+----------+-------+all the volumes are marked as recyclable, and the last Volume, File0007 has been purged, so it may be immediately recycled. The other volumes are all marked recyclable and when their Volume Retention period (14400 seconds or 4 hours) expires, they will be eligible for pruning, and possible recycling. Even though Volume File0007 has been purged, all the data on the Volume is still recoverable. A purged Volume simply means that there are no entries in the Catalog. Even if the Volume Status is changed to Recycle, the data on the Volume will be recoverable. The data is lost only when the Volume is re-labeled and re-written.
To modify Volume File0001 so that it cannot be recycled, you
use the update volume pool=File command in the console program,
or simply update and Bacula will prompt you for the information.
Making Bacula Use a Single TapeMost people will want Bacula to fill a tape and when it is full, a new tape will be mounted, and so on. However, as an extreme example, it is possible for Bacula to write on a single tape, and every night to rewrite it. To get this to work, you must do two things: first, set the VolumeRetention to less than your save period (one day), and the second item is to make Bacula mark the tape as full after using it once. This is done using UseVolumeOnce = yes. If this latter record is not used and the tape is not full after the first time it is written, Bacula will simply append to the tape and eventually request another volume. Using the tape only once, forces the tape to be marked Full after each use, and the next time Bacula runs, it will recycle the tape.An example Pool resource that does this is: Pool { Name = DDS-4 Use Volume Once = yes Pool Type = Backup AutoPrune = yes VolumeRetention = 12h # expire after 12 hours Recycle = yes } A Daily, Weekly, Monthly Tape Usage ExampleThis example is meant to show you how one could define a fixed set of volumes that Bacula will rotate through on a regular schedule. There are an infinite number of such schemes, all of which have various advantages and disadvantages.We start with the following assumptions:
What does this give? Well, at any point, you will have a the last complete Full save plus several Incremental saves. For any given file your want to recover (or your whole system), you will have a copy of that file every day for at least the last 14 days. For older versions, you will have at least 3 and probably 4 Friday full saves of that file, and going back further, you will have a copy of that file made on the beginning of the month for at least a year. So you have copies of any file (or your whole system) for at least a year, but as you go back in time, the time between copies increases from daily to weekly to monthly. What would the Bacula configuration look like to implement such a scheme? Schedule { Name = "NightlySave" Run = Level=Full Pool=Monthly 1st sat at 03:05 Run = Level=Full Pool=Weekly 2nd-5th sat at 03:05 Run = Level=Incremental Pool=Daily tue-fri at 03:05 } Job { Name = "NightlySave" Type = Backup Level = Full Client = LocalMachine FileSet = "File Set" Messages = Standard Storage = DDS-4 Pool = Daily Schedule = "NightlySave" } # Definition of file storage device Storage { Name = DDS-4 Address = localhost SDPort = 9103 Password = XXXXXXXXXXXXX Device = FileStorage Media Type = 8mm } FileSet { Name = "File Set" Include = signature=MD5 { fffffffffffffffff } Exclude = { *.o } } Pool { Name = Daily Pool Type = Backup AutoPrune = yes VolumeRetention = 10d # recycle in 10 days Maximum Volumes = 10 Recycle = yes } Pool { Name = Weekly Use Volume Once = yes Pool Type = Backup AutoPrune = yes VolumeRetention = 30d # recycle in 30 days (default) Recycle = yes } Pool { Name = Monthly Use Volume Once = yes Pool Type = Backup AutoPrune = yes VolumeRetention = 365d # recycle in 1 year Recycle = yes } Automatic Pruning and Recycling ExamplePerhaps the best way to understand the various resource records that come into play during automatic pruning and recycling is to run a Job that goes through the whole cycle. If you add the following resources to your Director's configuration file:Schedule { Name = "30 minute cycle" Run = Level=Full Pool=File Messages=Standard Storage=File hourly at 0:05 Run = Level=Full Pool=File Messages=Standard Storage=File hourly at 0:35 } Job { Name = "Filetest" Type = Backup Level = Full Client=XXXXXXXXXX FileSet="Test Files" Messages = Standard Storage = File Pool = File Schedule = "30 minute cycle" } # Definition of file storage device Storage { Name = File Address = XXXXXXXXXXX SDPort = 9103 Password = XXXXXXXXXXXXX Device = FileStorage Media Type = File } FileSet { Name = "Test Files" Include = signature=MD5 { fffffffffffffffff } Exclude = { *.o } } Pool { Name = File Use Volume Once = yes Pool Type = Backup LabelFormat = File AutoPrune = yes VolumeRetention = 4h Maximum Volumes = 12 Recycle = yes }Where you will need to replace the ffffffffff's by the appropriate files to be saved for your configuration. For the FileSet Include, choose a directory that has one or two megabytes maximum since there will probably be approximately 8 copies of the directory that Bacula will cycle through. In addition, you will need to add the following to your Storage daemon's configuration file: Device { Name = FileStorage Media Type = File Archive Device = /tmp LabelMedia = yes; # lets Bacula label unlabeled media Random Access = Yes; AutomaticMount = yes; # when device opened, read it RemovableMedia = no; AlwaysOpen = no; } With the above resources, Bacula will start a Job every half hour that saves a copy of the directory you chose to /tmp/File0001 ... /tmp/File0012. After 4 hours, Bacula will start recycling the backup Volumes (/tmp/File0001 ...). You should see this happening in the output produced. Bacula will automatically create the Volumes (Files) the first time it uses them. To turn it off, either delete all the resources you've added, or simply comment out the Schedule record in the Job resource. Manually Recycling VolumesAlthough automatic recycling of Volumes is implemented in version 1.20 and later (see the Automatic Recycling of Volumes chapter of this manual), you may want to manually force reuse (recycling) of a Volume.Assuming that you want to keep the Volume name, but you simply want to write new data on the tape, the steps to take are:
If you wish to reuse the tape by giving it a new name, follow the following steps:
For Bacula versions prior to 1.30 or to manually relabel the Volume, use the instructions below:
Please be aware that the delete command can be dangerous. Once it is done, to recover the File records, you must either restore your database as it was before the delete command, or use the bscan utility program to scan the tape and recreate the database entries.
|