I've made some changes that could help you, but I guess, just will work in MySQL and I don't know if could have some another performance impact.
1st) Create a function in MySQL to convert bytes to human readable and run some commands:
2st) How you have changed bacula database, and create a new function is necessary to change the script catalog backup:
before: exec("HOME='$wd' mysqldump -f --opt $args{db_name} > '$wd/$args{db_name}.sql'");
Another thing that could be done is just create the function and change sample_query.sql
Some outputs of commands (about ExpiresIn), there's no sufficient space in the screen.
*list media pool=Mensal
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
*list media pool=Mensal
+---------+--------------------+-----------+---------+----------+----------+--------------+---------+------+-----------+-----------+---------------------+---------------------+
| MediaId | VolumeName | VolStatus | Enabled | VolBytes | VolFiles | VolRetention | Recycle | Slot | InChanger | MediaType | LastWritten | ExpiresIn |
+---------+--------------------+-----------+---------+----------+----------+--------------+---------+------+-----------+-----------+---------------------+---------------------+
| 46 | Volume-Mensal-0001 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-06-09 15:30:57 | 2016-06-08 15:30:57 |
| 47 | Volume-Mensal-0002 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-06-09 15:43:32 | 2016-06-08 15:43:32 |
| 48 | Volume-Mensal-0003 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-06-09 16:07:09 | 2016-06-08 16:07:09 |
| 49 | Volume-Mensal-0004 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-06-09 16:23:25 | 2016-06-08 16:23:25 |
| 50 | Volume-Mensal-0005 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-07-03 17:14:34 | 2016-07-02 17:14:34 |
| 101 | Volume-Mensal-0006 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-07-03 22:18:27 | 2016-07-02 22:18:27 |
| 102 | Volume-Mensal-0007 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-07-03 22:31:50 | 2016-07-02 22:31:50 |
| 103 | Volume-Mensal-0008 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-07-03 22:44:58 | 2016-07-02 22:44:58 |
| 104 | Volume-Mensal-0009 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-07-03 22:53:59 | 2016-07-02 22:53:59 |
| 105 | Volume-Mensal-0010 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-08-07 21:30:30 | 2016-08-06 21:30:30 |
| 123 | Volume-Mensal-0011 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-08-07 21:41:30 | 2016-08-06 21:41:30 |
| 124 | Volume-Mensal-0012 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-08-07 21:53:46 | 2016-08-06 21:53:46 |
| 125 | Volume-Mensal-0013 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-08-07 22:04:13 | 2016-08-06 22:04:13 |
| 126 | Volume-Mensal-0014 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-08-07 22:16:48 | 2016-08-06 22:16:48 |
| 127 | Volume-Mensal-0015 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-09-04 21:31:21 | 2016-09-03 21:31:21 |
| 129 | Volume-Mensal-0016 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-09-04 21:41:57 | 2016-09-03 21:41:57 |
| 130 | Volume-Mensal-0017 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-09-04 21:54:32 | 2016-09-03 21:54:32 |
| 131 | Volume-Mensal-0018 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-09-04 22:04:59 | 2016-09-03 22:04:59 |
| 132 | Volume-Mensal-0019 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-09-04 22:17:00 | 2016-09-03 22:17:00 |
| 133 | Volume-Mensal-0020 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-10-02 21:31:24 | 2016-10-01 21:31:24 |
| 155 | Volume-Mensal-0021 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-10-02 21:41:54 | 2016-10-01 21:41:54 |
| 156 | Volume-Mensal-0022 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-10-02 21:54:02 | 2016-10-01 21:54:02 |
| 157 | Volume-Mensal-0023 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-10-02 22:05:11 | 2016-10-01 22:05:11 |
| 158 | Volume-Mensal-0024 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-10-02 22:13:17 | 2016-10-01 22:13:17 |
| 159 | Volume-Mensal-0025 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-11-06 17:11:17 | 2016-11-05 17:11:17 |
| 160 | Volume-Mensal-0026 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-11-06 21:35:14 | 2016-11-05 21:35:14 |
| 161 | Volume-Mensal-0027 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-11-06 21:46:54 | 2016-11-05 21:46:54 |
| 162 | Volume-Mensal-0028 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-11-06 21:59:06 | 2016-11-05 21:59:06 |
| 163 | Volume-Mensal-0029 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-11-06 22:09:46 | 2016-11-05 22:09:46 |
| 164 | Volume-Mensal-0030 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-11-06 22:19:29 | 2016-11-05 22:19:29 |
| 165 | Volume-Mensal-0031 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-12-04 17:16:20 | 2016-12-03 17:16:20 |
| 166 | Volume-Mensal-0032 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-12-04 21:39:09 | 2016-12-03 21:39:09 |
| 167 | Volume-Mensal-0033 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-12-04 21:51:32 | 2016-12-03 21:51:32 |
| 168 | Volume-Mensal-0034 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-12-04 22:02:34 | 2016-12-03 22:02:34 |
| 169 | Volume-Mensal-0035 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-12-04 22:12:04 | 2016-12-03 22:12:04 |
| 170 | Volume-Mensal-0036 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2015-12-04 22:25:17 | 2016-12-03 22:25:17 |
| 171 | Volume-Mensal-0037 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2016-01-01 21:34:45 | 2016-12-31 21:34:45 |
| 172 | Volume-Mensal-0038 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2016-01-01 21:46:14 | 2016-12-31 21:46:14 |
| 173 | Volume-Mensal-0039 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2016-01-01 21:58:05 | 2016-12-31 21:58:05 |
| 174 | Volume-Mensal-0040 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2016-01-01 22:08:39 | 2016-12-31 22:08:39 |
| 175 | Volume-Mensal-0041 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2016-01-01 22:17:10 | 2016-12-31 22:17:10 |
| 176 | Volume-Mensal-0042 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2016-02-05 17:13:11 | 2017-02-04 17:13:11 |
| 177 | Volume-Mensal-0043 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2016-02-05 21:38:39 | 2017-02-04 21:38:39 |
| 178 | Volume-Mensal-0044 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2016-02-05 21:56:40 | 2017-02-04 21:56:40 |
| 179 | Volume-Mensal-0045 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2016-02-05 22:17:27 | 2017-02-04 22:17:27 |
| 180 | Volume-Mensal-0046 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2016-02-05 22:35:27 | 2017-02-04 22:35:27 |
| 181 | Volume-Mensal-0047 | Full | 1 | 3.73 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2016-02-05 22:54:48 | 2017-02-04 22:54:48 |
| 182 | Volume-Mensal-0048 | Append | 1 | 1.36 GB | 0 | 31,536,000 | 1 | 0 | 0 | File | 2016-02-05 23:05:01 | 2017-02-04 23:05:01 |
+---------+--------------------+-----------+---------+----------+----------+--------------+---------+------+-----------+-----------+---------------------+---------------------+