Z
Z
Zyo2017-01-30 11:14:34
linux
Zyo, 2017-01-30 11:14:34

How to teach bareos/bacula to delete used volumes and automatically create new ones?

Tell me, please, who set up Bacula or its Bareos fork for backup?
What is the essence of the problem: there is not much space on the partition, data for backup is right next to it. I do a daily full backup of muscle databases, once a week a full backup of files and daily incremental files. I want Bareos to correctly either: a) delete old volumes and create new ones after a specified period; b) correctly used already completed and overdue. Now my director of the periodical either hangs in anticipation of free space, or offers to create new volumes.
Here is an example volume config:
MySQL

Pool {
  Name = Mysql
  Pool Type = Backup
  Use Volume Once = no
  Recycle = yes
  AutoPrune = yes
  Recycle Oldest Volume = no      # Это пробовалось для удаления просроченых томов. Можно и закаментить.
  ActionOnPurge = Truncate
  Volume Retention = 3 days         # How long should the Full Backups be kept?
  Maximum Volume Bytes = 700M          # Limit Volume size to something reasonab
  Maximum Volumes = 20              # Limit number of Volumes in Pool
  Label Format = "Mysql-"              # Volumes will be labeled "Full-<volume-i
}

Those. I want to keep the last 3 backups. All volumes that are overdue > 3 days - delete and replace with new ones or just use it again.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
Zyo, 2017-02-15
@Zyo

Thanks for the answer. I saw this script, it helped me at the beginning of the struggle for a place.
With the place everything is pretty predictable for me, the main thing is that the volumes are reused. Now everything works as I want with this config.

Pool {
  Name = Mysql
  Pool Type = Backup
  Recycle = yes                       # Bareos can automatically recycle Volumes
  AutoPrune = yes                     # Prune expired volumes
  Volume Retention = 2 days         # How long should the Full Backups be kept?
  Maximum Volume Bytes = 700M          # Limit Volume size to something reasonab
  Maximum Volumes = 20              # Limit number of Volumes in Pool
  Label Format = "Mysql-"              # Volumes will be labeled "Full-<volume-i
}

In theory, if my memory serves me, then almost exactly the same parameters are used by default, but for some reason I didn’t start from the start.
Thanks again for your reply. I think the issue is closed.

Y
younghacker, 2017-02-03
@younghacker

Each pool and task has a Volume Retention parameter that sets the time after which the files that got into this volume are considered deleted by the bacula. If the AutoPrune = yes option is set then bacula will remove entries from the directory (SQL). And if the option ActionOnPurge = Truncate is set, then it will cut the file size to zero.
You need to understand one thing for yourself: bacula / bareos is sharpened for tapes and perceives files as tapes. And behaves accordingly, reuses them if the parameter Maximum Volume Jobs = 1 is not set . The problem is that my backup volume is growing and it is difficult to understand how much to store. And it often happened that some volume swelled and filled the disk . After all, most of us use disks, not tapes. Deleting such volumes is tricky, especially when the job is "spread out" over several tape files.
Therefore, for myself, I decided that the tasks will have a certain format directly related to the server name, backup type and date. In this case, the deletion queue is obvious. In addition, there are no big problems when restoring from only one backup file (without the SQL catalog, I had to do this several times) since the entire task is entirely in one file.
You can take the script from herefix it for your task and add it to cron. Remember that this script is for manual launch. It is interactive and deletes files by date and no matter how many files are left. In other words, if a backup is not created, this script, when executed, will delete files. And eventually delete all backups. By the way, instead of a cron script, you can insert it into a handler, for example, a directory. Put the backup of the SQL directory at the end of the queue and add the "RunScript after/Run After Job" task to it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question