/etc/bacula/scripts/make_catalog_backup_awk is in bacula-director-mysql 5.2.5-0ubuntu6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #!/usr/bin/gawk -f
# extract.awk script expects Catalog definition in a form of:
# Catalog {
# Name = NameOfCatalog
# dbname = ""; DB Address = ""; user = ""; password = ""; DB Socket = ""; DB Port = ""
# }
#
BEGIN { RS= "}" ; FS="[;\n]+"}
function trim(v) {
## Remove leading and trailing spaces
sub(/^ */,"",v)
sub(/ *$/,"",v)
return v
}
$0 ~ /Catalog[[:space:]]*{/ {
for ( i = 1; i <= NF ; i++)
{
split($i,a,"=")
if (a[1] ~ /dbname/)
dbname = trim(gensub("\"","","g",a[2])) # remove " char
if (a[1] ~ /user/)
user = trim(gensub("\"","","g",a[2]))
if (a[1] ~ /Name/)
catname = trim(gensub("\"","","g",a[2]))
if (a[1] ~ /password/)
password = trim(gensub("\"","","g",a[2]))
if (a[1] ~ /DB Address/)
dbaddress = trim(gensub("\"","","g",a[2]))
if (a[1] ~ /DB Socket/)
dbsocket = trim(gensub("\"","","g",a[2]))
if (a[1] ~ /DB Port/)
dbport = trim(gensub("\"","","g",a[2]))
}
if (catname == cat1 || catname == cat2 || catname == cat3 || catname == cat4) {
if (dbaddress == "") #Not optional in the case of MySQL
dbaddress = "localhost"
system("rm -rf /var/lib/bacula/.my.cnf")
system("touch /var/lib/bacula/.my.cnf")
system("chmod 600 /var/lib/bacula/.my.cnf")
printf "[client]\n host=%s\n user=%s\n password=%s\n",dbaddress,user,password >> "/var/lib/bacula/.my.cnf"
if (dbport != "")
printf " port=%s\n",dbport >> "/var/lib/bacula/.my.cnf"
if (dbsocket != "")
printf " socket=%s\n",dbsocket >> "/var/lib/bacula/.my.cnf"
system(sprintf ("HOME=/var/lib/bacula mysqldump %s > /var/lib/bacula/bacula.sql",dbname))
}
}
|