Volume Recycling
By default, once Bacula starts writing a Volume, it may append to the volume, but it will not overwrite the existing data thus destroying it. However when Bacula recycles a Volume, the Volume becomes available for being reused, and Bacula can at some later time overwrite the previous contents of that Volume. At that point all previous data on that Volume will be lost. If the Volume is a tape, the tape will be rewritten from the beginning. If the Volume is a disk file, the file will be truncated before being rewritten.
You may not want Bacula to automatically recycle (reuse) Volumes. Doing so may require a large number of Volumes though. However, it is also possible to manually recycle Volumes so that they may be reused. For more on manual recycling, see the section entitled Manually Recycling Volumes.
Most people prefer to have a Pool of Volumes that are used for daily backups and recycled once a week, another Pool of Volumes that are used for Full backups once a week and recycled monthly, and finally a Pool of Volumes that are used once a month and recycled after a year or two. With a scheme like this, the number of Volumes in your pool or pools remains constant.
By properly defining your Volume Pools with appropriate Retention periods, Bacula can manage the recycling (such as defined above) automatically.
Automatic Volume Recycling
Automatic recycling of Volumes is controlled by four records in the resource definition in the Director’s configuration file. These four records are:
AutoPrune = yes
VolumeRetention = <time>
Recycle = yes
RecyclePool = <APool>
ScratchPool = <APool>
The above first three directives are all you need assuming that you fill each of your Volumes then wait the Volume Retention period before reusing them, providing there is some non-pruned Jobs or Files on the Volume. Recycle Pool and Scratch Pool directives are not required. If not defined, Bacula will recycle Volumes and keep them in the current Pool.
If you want Bacula to stop using a Volume and recycle it before it is full, you will need to use one or more additional directives such as:
Use Volume Once=yes
Volume Use Duration=ttt
Maximum Volume Jobs=nnn
Maximum Volume Bytes=mmm
See below and the Basic Volume Management chapter for complete examples.
Automatic recycling of Volumes is performed by Bacula only when it wants a new Volume and no appendable Volumes are available in the Pool. It will then search the Pool for any Volumes with the flag set and the Volume Status is. At that point, it will choose the oldest purged volume and recycle it.
If there are no volumes with status, then the recycling occurs in two steps:
The first is that the Catalog for a Volume must be pruned of all Jobs (i.e. Purged) and Files contained on that Volume.
The second step is the actual recycling of the Volume. Only Volumes marked or will be considered for pruning. The Volume will be purged, all Jobs and Files associated to this Volume are pruned from Catalog, if the VolumeRetention period has expired. When a Volume is marked as , it means that no Catalog records for Jobs and Files reference that Volume, and the Volume can be recycled and reused. Please note a Volume can be reused even though the VolumeRetention period has not expired if the Jobs and Files associated to the Volume had been already pruned. Until recycling actually occurs, the Volume data remains intact. If no Volumes can be found for recycling for any of the reasons stated above, Bacula will request operator intervention (i.e. it will ask you to label a new volume).
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, otherwise, it will always write to an appendable Volume before recycling even if there are Volumes marked as . This preserves your data as long as possible. 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. If necessary, you can manually set a volume to. The reason for this is that Bacula wants to preserve the data on your old Volumes (even though purged from the catalog) as long as absolutely possible before overwriting it. There are also a number of directives such as Volume Use Duration that will automatically mark a volume as and thus no longer appendable.
Manually Recycling Volumes
Although automatic recycling of Volumes is implemented in version 1.20 and later (see the Automatic Recycling of Volumes), 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:
Use the update volume command in the Console to ensure that the field is set to 1
Use the purge jobs volume command in the Console to mark the Volume as Purged. Check by using list volumes.
Once the Volume is marked Purged, it will be recycled the next time a Volume is needed.
If you wish to reuse the volume by giving it a new name, follow the following steps:
Use the purge jobs volume command in the Console to mark the Volume as Purged. Check by using list volumes.
Use the Console relabel command to relabel the Volume.
Please note that the relabel command applies only to tape Volumes.
For Bacula versions prior to 1.30 or to manually relabel the Volume, use the instructions below:
Use the delete volume command in the Console to delete the Volume from the Catalog.
If a different tape is mounted, use the unmount command, remove the tape, and insert the tape to be renamed.
Write an EOF mark in the tape using the following commands:
mt -f /dev/nst0 rewind mt -f /dev/nst0 weof
where you replace /dev/nst0 with the appropriate device name on your system.
Use the label command to write a new label to the tape and to enter it in the catalog.
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.
Specificities of Tape Recycling
Most 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. 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 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
}
Regular Schedule Tape Usage Example
This 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. Note: these volumes may either be tape volumes or disk volumes.
We start with the following assumptions:
A single tape has more than enough capacity to do a full save.
There are ten tapes that are used on a daily basis for incremental backups. They are prelabeled Daily1 … Daily10.
There are four tapes that are used on a weekly basis for full backups. They are labeled Week1 … Week4.
There are 12 tapes that are used on a monthly basis for full backups. They are numbered Month1 … Month12
A full backup is done every Saturday evening (tape inserted Friday evening before leaving work).
No backups are done over the weekend (this is easy to change).
The first Friday of each month, a Monthly tape is used for the Full backup.
Incremental backups are done Monday - Friday (actually Tue-Fri mornings).
We start the system by doing a Full save to one of the weekly volumes or one of the monthly volumes. The next morning, we remove the tape and insert a Daily tape. Friday evening, we remove the Daily tape and insert the next tape in the Weekly series. Monday, we remove the Weekly tape and re-insert the Daily tape. On the first Friday of the next month, we insert the next Monthly tape in the series rather than a Weekly tape, then continue. When a Daily tape finally fills up, Bacula will request the next one in the series, and the next day when you notice the email message, you will mount it and Bacula will finish the unfinished incremental backup.
What does this give? Well, at any point, you will have the last complete Full save plus several Incremental saves. For any given file you 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 three and probably four 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 {
Options { signature=MD5 }
File = fffffffffffffffff
}
Exclude { File=*.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
}
Go back to the Storage Space Management chapter.
Go back to the main Bacula Enterprise Management page.