2 Bacula® - The Network Backup Solution
4 Copyright (C) 2002-2008 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version two of the GNU General Public
10 License as published by the Free Software Foundation and included
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of Kern Sibbald.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
30 * Bacula Director -- Automatic Recycling of Volumes
31 * Recycles Volumes that have been purged
33 * Kern Sibbald, May MMII
43 /* Forward referenced functions */
45 bool find_recycled_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
47 bstrncpy(mr->VolStatus, "Recycle", sizeof(mr->VolStatus));
48 if (db_find_next_volume(jcr, jcr->db, 1, InChanger, mr)) {
49 jcr->MediaId = mr->MediaId;
50 Dmsg1(20, "Find_next_vol MediaId=%u\n", jcr->MediaId);
51 pm_strcpy(jcr->VolumeName, mr->VolumeName);
58 * Look for oldest Purged volume
60 bool recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
62 bstrncpy(mr->VolStatus, "Purged", sizeof(mr->VolStatus));
63 if (db_find_next_volume(jcr, jcr->db, 1, InChanger, mr)) {
64 if (recycle_volume(jcr, mr)) {
65 Jmsg(jcr, M_INFO, 0, _("Recycled volume \"%s\"\n"), mr->VolumeName);
66 Dmsg1(100, "return 1 recycle_oldest_purged_volume Vol=%s\n", mr->VolumeName);
70 Dmsg0(100, "return 0 recycle_oldest_purged_volume end\n");
75 * Recycle the specified volume
77 int recycle_volume(JCR *jcr, MEDIA_DBR *mr)
79 bstrncpy(mr->VolStatus, "Recycle", sizeof(mr->VolStatus));
80 mr->VolJobs = mr->VolFiles = mr->VolBlocks = mr->VolErrors = 0;
82 mr->FirstWritten = mr->LastWritten = 0;
84 mr->set_first_written = true;
85 return db_update_media_record(jcr, jcr->db, mr);