[bacula/el5] First attempt in fixing make_catalog_backup (rhbz#456612)
Simone Caronni
slaanesh at fedoraproject.org
Thu Jul 26 14:51:43 UTC 2012
commit 51c349cf1aaac4a7cd0c962b60f1ecb38aaf769f
Author: Simone Caronni <negativo17 at gmail.com>
Date: Thu Jul 26 16:51:36 2012 +0200
First attempt in fixing make_catalog_backup (rhbz#456612)
bacula-2.4.4-make_catalog_backup.patch | 354 ++++++++++++++++++++++++++++++++
1 files changed, 354 insertions(+), 0 deletions(-)
---
diff --git a/bacula-2.4.4-make_catalog_backup.patch b/bacula-2.4.4-make_catalog_backup.patch
new file mode 100644
index 0000000..1a30f97
--- /dev/null
+++ b/bacula-2.4.4-make_catalog_backup.patch
@@ -0,0 +1,354 @@
+diff -Naur bacula-2.4.4.old/autoconf/configure.in bacula-2.4.4/autoconf/configure.in
+--- bacula-2.4.4.old/autoconf/configure.in 2012-07-26 16:34:45.123961758 +0200
++++ bacula-2.4.4/autoconf/configure.in 2012-07-26 16:38:08.048948147 +0200
+@@ -2221,7 +2221,7 @@
+ src/filed/Makefile \
+ src/filed/bacula-fd.conf \
+ src/cats/Makefile \
+- src/cats/make_catalog_backup \
++ src/cats/make_catalog_backup.pl \
+ src/cats/delete_catalog_backup \
+ src/cats/create_postgresql_database \
+ src/cats/update_postgresql_tables \
+@@ -2318,7 +2318,7 @@
+ chmod 755 $c/create_postgresql_database $c/update_postgresql_tables $c/make_postgresql_tables
+ chmod 755 $c/grant_postgresql_privileges $c/drop_postgresql_tables $c/drop_postgresql_database
+
+-chmod 755 $c/make_catalog_backup $c/delete_catalog_backup
++chmod 755 $c/make_catalog_backup.pl $c/delete_catalog_backup
+ chmod 755 $c/sqlite
+ chmod 755 $c/mysql
+
+diff -Naur bacula-2.4.4.old/configure bacula-2.4.4/configure
+--- bacula-2.4.4.old/configure 2012-07-26 16:34:45.339965999 +0200
++++ bacula-2.4.4/configure 2012-07-26 16:38:37.673527663 +0200
+@@ -30126,7 +30126,7 @@
+ exit 1
+ fi
+
+-ac_config_files="$ac_config_files autoconf/Make.common Makefile manpages/Makefile scripts/startmysql scripts/stopmysql scripts/btraceback scripts/startit scripts/stopit scripts/bconsole scripts/gconsole scripts/bacula scripts/bacula-ctl-dir scripts/bacula-ctl-fd scripts/bacula-ctl-sd scripts/devel_bacula scripts/Makefile scripts/logrotate scripts/bacula.desktop.gnome1 scripts/bacula.desktop.gnome2 scripts/bacula.desktop.gnome1.consolehelper scripts/bacula.desktop.gnome2.consolehelper scripts/bacula.desktop.gnome1.xsu scripts/bacula.desktop.gnome2.xsu scripts/bgnome-console.console_apps scripts/mtx-changer scripts/disk-changer scripts/dvd-handler scripts/dvd-simulator scripts/bacula-tray-monitor.desktop scripts/logwatch/Makefile scripts/logwatch/logfile.bacula.conf scripts/wxconsole.console_apps scripts/wxconsole.desktop.consolehelper scripts/wxconsole.desktop.xsu scripts/bat.desktop scripts/bat.desktop.xsu scripts/bat.desktop.consolehelper scripts/bat.console_apps src/Makef
ile src/host.h src/console/Makefile src/console/bconsole.conf src/gnome2-console/Makefile src/gnome2-console/bgnome-console.conf src/qt-console/bat.conf src/qt-console/bat.pro src/qt-console/install_conf_file src/wx-console/Makefile src/wx-console/bwx-console.conf src/tray-monitor/Makefile src/tray-monitor/tray-monitor.conf src/dird/Makefile src/dird/bacula-dir.conf src/lib/Makefile src/stored/Makefile src/stored/bacula-sd.conf src/filed/Makefile src/filed/bacula-fd.conf src/cats/Makefile src/cats/make_catalog_backup src/cats/delete_catalog_backup src/cats/create_postgresql_database src/cats/update_postgresql_tables src/cats/make_postgresql_tables src/cats/grant_postgresql_privileges src/cats/drop_postgresql_tables src/cats/drop_postgresql_database src/cats/create_mysql_database src/cats/update_mysql_tables src/cats/make_mysql_tables src/cats/grant_mysql_privileges src/cats/drop_mysql_tables src/cats/drop_mysql_database src/cats/create_sqlite_database src/cats/update_sqlite_
tables src/cats/make_sqlite_tables src/cats/grant_sqlite_privileges src/cats/drop_sqlite_tables src/cats/drop_sqlite_database src/cats/create_sqlite3_database src/cats/update_sqlite3_tables src/cats/make_sqlite3_tables src/cats/grant_sqlite3_privileges src/cats/drop_sqlite3_tables src/cats/drop_sqlite3_database src/cats/sqlite src/cats/mysql src/cats/create_bdb_database src/cats/update_bdb_tables src/cats/make_bdb_tables src/cats/grant_bdb_privileges src/cats/drop_bdb_tables src/cats/drop_bdb_database src/cats/create_bacula_database src/cats/update_bacula_tables src/cats/grant_bacula_privileges src/cats/make_bacula_tables src/cats/drop_bacula_tables src/cats/drop_bacula_database src/findlib/Makefile src/tools/Makefile po/Makefile.in $PFILES"
++ac_config_files="$ac_config_files autoconf/Make.common Makefile manpages/Makefile scripts/startmysql scripts/stopmysql scripts/btraceback scripts/startit scripts/stopit scripts/bconsole scripts/gconsole scripts/bacula scripts/bacula-ctl-dir scripts/bacula-ctl-fd scripts/bacula-ctl-sd scripts/devel_bacula scripts/Makefile scripts/logrotate scripts/bacula.desktop.gnome1 scripts/bacula.desktop.gnome2 scripts/bacula.desktop.gnome1.consolehelper scripts/bacula.desktop.gnome2.consolehelper scripts/bacula.desktop.gnome1.xsu scripts/bacula.desktop.gnome2.xsu scripts/bgnome-console.console_apps scripts/mtx-changer scripts/disk-changer scripts/dvd-handler scripts/dvd-simulator scripts/bacula-tray-monitor.desktop scripts/logwatch/Makefile scripts/logwatch/logfile.bacula.conf scripts/wxconsole.console_apps scripts/wxconsole.desktop.consolehelper scripts/wxconsole.desktop.xsu scripts/bat.desktop scripts/bat.desktop.xsu scripts/bat.desktop.consolehelper scripts/bat.console_apps src/Makef
ile src/host.h src/console/Makefile src/console/bconsole.conf src/gnome2-console/Makefile src/gnome2-console/bgnome-console.conf src/qt-console/bat.conf src/qt-console/bat.pro src/qt-console/install_conf_file src/wx-console/Makefile src/wx-console/bwx-console.conf src/tray-monitor/Makefile src/tray-monitor/tray-monitor.conf src/dird/Makefile src/dird/bacula-dir.conf src/lib/Makefile src/stored/Makefile src/stored/bacula-sd.conf src/filed/Makefile src/filed/bacula-fd.conf src/cats/Makefile src/cats/make_catalog_backup.pl src/cats/delete_catalog_backup src/cats/create_postgresql_database src/cats/update_postgresql_tables src/cats/make_postgresql_tables src/cats/grant_postgresql_privileges src/cats/drop_postgresql_tables src/cats/drop_postgresql_database src/cats/create_mysql_database src/cats/update_mysql_tables src/cats/make_mysql_tables src/cats/grant_mysql_privileges src/cats/drop_mysql_tables src/cats/drop_mysql_database src/cats/create_sqlite_database src/cats/update_sqli
te_tables src/cats/make_sqlite_tables src/cats/grant_sqlite_privileges src/cats/drop_sqlite_tables src/cats/drop_sqlite_database src/cats/create_sqlite3_database src/cats/update_sqlite3_tables src/cats/make_sqlite3_tables src/cats/grant_sqlite3_privileges src/cats/drop_sqlite3_tables src/cats/drop_sqlite3_database src/cats/sqlite src/cats/mysql src/cats/create_bdb_database src/cats/update_bdb_tables src/cats/make_bdb_tables src/cats/grant_bdb_privileges src/cats/drop_bdb_tables src/cats/drop_bdb_database src/cats/create_bacula_database src/cats/update_bacula_tables src/cats/grant_bacula_privileges src/cats/make_bacula_tables src/cats/drop_bacula_tables src/cats/drop_bacula_database src/findlib/Makefile src/tools/Makefile po/Makefile.in $PFILES"
+
+ ac_config_commands="$ac_config_commands default"
+
+@@ -30759,7 +30759,7 @@
+ "src/filed/Makefile") CONFIG_FILES="$CONFIG_FILES src/filed/Makefile" ;;
+ "src/filed/bacula-fd.conf") CONFIG_FILES="$CONFIG_FILES src/filed/bacula-fd.conf" ;;
+ "src/cats/Makefile") CONFIG_FILES="$CONFIG_FILES src/cats/Makefile" ;;
+- "src/cats/make_catalog_backup") CONFIG_FILES="$CONFIG_FILES src/cats/make_catalog_backup" ;;
++ "src/cats/make_catalog_backup.pl") CONFIG_FILES="$CONFIG_FILES src/cats/make_catalog_backup.pl" ;;
+ "src/cats/delete_catalog_backup") CONFIG_FILES="$CONFIG_FILES src/cats/delete_catalog_backup" ;;
+ "src/cats/create_postgresql_database") CONFIG_FILES="$CONFIG_FILES src/cats/create_postgresql_database" ;;
+ "src/cats/update_postgresql_tables") CONFIG_FILES="$CONFIG_FILES src/cats/update_postgresql_tables" ;;
+@@ -31806,7 +31806,7 @@
+ chmod 755 $c/create_postgresql_database $c/update_postgresql_tables $c/make_postgresql_tables
+ chmod 755 $c/grant_postgresql_privileges $c/drop_postgresql_tables $c/drop_postgresql_database
+
+-chmod 755 $c/make_catalog_backup $c/delete_catalog_backup
++chmod 755 $c/make_catalog_backup.pl $c/delete_catalog_backup
+ chmod 755 $c/sqlite
+ chmod 755 $c/mysql
+
+diff -Naur bacula-2.4.4.old/Makefile.in bacula-2.4.4/Makefile.in
+--- bacula-2.4.4.old/Makefile.in 2012-07-26 16:34:45.339965999 +0200
++++ bacula-2.4.4/Makefile.in 2012-07-26 16:44:06.934991407 +0200
+@@ -186,7 +186,8 @@
+ chmod 755 grant_bacula_privileges drop_bacula_tables drop_bacula_database; \
+ chmod 755 create_ at DB_TYPE@_database update_ at DB_TYPE@_tables make_ at DB_TYPE@_tables; \
+ chmod 755 grant_ at DB_TYPE@_privileges drop_ at DB_TYPE@_tables drop_ at DB_TYPE@_database; \
+- chmod 755 make_catalog_backup delete_catalog_backup)
++ chmod 755 make_catalog_backup.pl delete_catalog_backup; \
++ ln -sf make_catalog_backup.pl make_catalog_backup)
+
+ clean:
+ @for I in ${all_subdirs} src/win32; \
+diff -Naur bacula-2.4.4.old/src/cats/make_catalog_backup.in bacula-2.4.4/src/cats/make_catalog_backup.in
+--- bacula-2.4.4.old/src/cats/make_catalog_backup.in 2012-07-26 16:34:45.146962210 +0200
++++ bacula-2.4.4/src/cats/make_catalog_backup.in 1970-01-01 01:00:00.000000000 +0100
+@@ -1,72 +0,0 @@
+-#!/bin/sh
+-#
+-# This script dumps your Bacula catalog in ASCII format
+-# It works for MySQL, SQLite, and PostgreSQL
+-#
+-# $1 is the name of the database to be backed up and the name
+-# of the output file (default = bacula).
+-# $2 is the user name with which to access the database
+-# (default = bacula).
+-# $3 is the password with which to access the database or "" if no password
+-# (default ""). WARNING!!! Passing the password via the command line is
+-# insecure and should not be used since any user can display the command
+-# line arguments and the environment using ps. Please consult your
+-# MySQL or PostgreSQL manual for secure methods of specifying the
+-# password.
+-# $4 is the host on which the database is located
+-# (default "")
+-#
+-#
+-BINDIR=@SQL_BINDIR@
+-
+-cd @working_dir@
+-rm -f $1.sql
+-if test xsqlite = x at DB_TYPE@ ; then
+- echo ".dump" | ${BINDIR}/sqlite $1.db >$1.sql
+-else
+- if test xmysql = x at DB_TYPE@ ; then
+- if test $# -gt 2; then
+- MYSQLPASSWORD=" --password=$3"
+- else
+- MYSQLPASSWORD=""
+- fi
+- if test $# -gt 3; then
+- MYSQLHOST=" --host=$4"
+- else
+- MYSQLHOST=""
+- fi
+- ${BINDIR}/mysqldump -u ${2}${MYSQLPASSWORD}${MYSQLHOST} -f --opt $1 >$1.sql
+- else
+- if test xpostgresql = x at DB_TYPE@ ; then
+- if test $# -gt 2; then
+- PGPASSWORD=$3
+- export PGPASSWORD
+- fi
+- if test $# -gt 3; then
+- PGHOST=" --host=$4"
+- else
+- PGHOST=""
+- fi
+- exec ${BINDIR}/pg_dump -c $PGHOST -U $2 $1 >$1.sql
+- else
+- echo ".dump" | ${BINDIR}/sqlite3 $1.db >$1.sql
+- fi
+- fi
+-fi
+-#
+-# To read back a MySQL database use:
+-# cd @working_dir@
+-# rm -f ${BINDIR}/../var/bacula/*
+-# mysql <bacula.sql
+-#
+-# To read back a SQLite database use:
+-# cd @working_dir@
+-# rm -f bacula.db
+-# sqlite bacula.db <bacula.sql
+-#
+-# To read back a PostgreSQL database use:
+-# cd @working_dir@
+-# dropdb bacula
+-# createdb bacula
+-# psql bacula <bacula.sql
+-#
+diff -Naur bacula-2.4.4.old/src/cats/make_catalog_backup.pl.in bacula-2.4.4/src/cats/make_catalog_backup.pl.in
+--- bacula-2.4.4.old/src/cats/make_catalog_backup.pl.in 1970-01-01 01:00:00.000000000 +0100
++++ bacula-2.4.4/src/cats/make_catalog_backup.pl.in 2012-07-26 16:31:02.536591624 +0200
+@@ -0,0 +1,162 @@
++#!/usr/bin/env perl
++use strict;
++
++=head1 SCRIPT
++
++ This script dumps your Bacula catalog in ASCII format
++ It works for MySQL, SQLite, and PostgreSQL
++
++=head1 USAGE
++
++ make_catalog_backup.pl MyCatalog
++
++=head1 LICENSE
++
++ Bacula® - The Network Backup Solution
++
++ Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
++
++ The main author of Bacula is Kern Sibbald, with contributions from
++ many others, a complete list can be found in the file AUTHORS.
++
++ This program is Free Software; you can redistribute it and/or
++ modify it under the terms of version three of the GNU Affero General Public
++ License as published by the Free Software Foundation plus additions
++ that are listed in the file LICENSE.
++
++ This program is distributed in the hope that it will be useful, but
++ WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ General Public License for more details.
++
++ You should have received a copy of the GNU Affero General Public License
++ along with this program; if not, write to the Free Software
++ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
++ 02110-1301, USA.
++
++ Bacula® is a registered trademark of Kern Sibbald.
++ The licensor of Bacula is the Free Software Foundation Europe
++ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zurich,
++ Switzerland, email:ftf at fsfeurope.org.
++
++=cut
++
++my $cat = shift or die "Usage: $0 catalogname";
++my $dir_conf='@sbindir@/dbcheck -B -c @sysconfdir@/bacula-dir.conf';
++my $wd = "@working_dir@";
++
++sub dump_sqlite3
++{
++ my %args = @_;
++
++ exec("echo .dump | sqlite3 '$wd/$args{db_name}.db' > '$wd/$args{db_name}.sql'");
++ print "Error while executing sqlite dump $!\n";
++ return 1;
++}
++
++# TODO: use just ENV and drop the pg_service.conf file
++sub dump_pgsql
++{
++ my %args = @_;
++ umask(0077);
++
++ if ($args{db_address}) {
++ $ENV{PGHOST}=$args{db_address};
++ }
++ if ($args{db_socket}) {
++ $ENV{PGHOST}=$args{db_socket};
++ }
++ if ($args{db_port}) {
++ $ENV{PGPORT}=$args{db_port};
++ }
++ if ($args{db_user}) {
++ $ENV{PGUSER}=$args{db_user};
++ }
++ if ($args{db_password}) {
++ $ENV{PGPASSWORD}=$args{db_password};
++ }
++ $ENV{PGDATABASE}=$args{db_name};
++ exec("HOME='$wd' pg_dump -c > '$wd/$args{db_name}.sql'");
++ print "Error while executing postgres dump $!\n";
++ return 1; # in case of error
++}
++
++sub dump_mysql
++{
++ my %args = @_;
++ umask(0077);
++ unlink("$wd/.my.cnf");
++ open(MY, ">$wd/.my.cnf")
++ or die "Can't open $wd/.my.cnf for writing $@";
++
++ $args{db_address} = $args{db_address} || "localhost";
++ my $addr = "host=$args{db_address}";
++ if ($args{db_socket}) { # unix socket is fastest than net socket
++ $addr = "socket=$args{db_socket}";
++ }
++
++ print MY "[client]
++$addr
++user=$args{db_user}
++password=$args{db_password}
++";
++ if ($args{db_port}) {
++ print MY "port=$args{db_port}\n";
++ }
++
++ close(MY);
++
++ exec("HOME='$wd' mysqldump -f --opt $args{db_name} > '$wd/$args{db_name}.sql'");
++ print "Error while executing mysql dump $!\n";
++ return 1;
++}
++
++sub dump_catalog
++{
++ my %args = @_;
++ if ($args{db_type} eq 'SQLite3') {
++ $ENV{PATH}="@SQLITE_BINDIR@:$ENV{PATH}";
++ dump_sqlite3(%args);
++ } elsif ($args{db_type} eq 'PostgreSQL') {
++ $ENV{PATH}="@POSTGRESQL_BINDIR@:$ENV{PATH}";
++ dump_pgsql(%args);
++ } elsif ($args{db_type} eq 'MySQL') {
++ $ENV{PATH}="@MYSQL_BINDIR@:$ENV{PATH}";
++ dump_mysql(%args);
++ } else {
++ die "This database type isn't supported";
++ }
++}
++
++open(FP, "$dir_conf -C '$cat'|") or die "Can't get catalog information $@";
++# catalog=MyCatalog
++# db_type=SQLite
++# db_name=regress
++# db_driver=
++# db_user=regress
++# db_password=
++# db_address=
++# db_port=0
++# db_socket=
++my %cfg;
++
++while(my $l = <FP>)
++{
++ if ($l =~ /catalog=(.+)/) {
++ if (exists $cfg{catalog} and $cfg{catalog} eq $cat) {
++ exit dump_catalog(%cfg);
++ }
++ %cfg = (); # reset
++ }
++
++ if ($l =~ /(\w+)=(.+)/) {
++ $cfg{$1}=$2;
++ }
++}
++
++if (exists $cfg{catalog} and $cfg{catalog} eq $cat) {
++ exit dump_catalog(%cfg);
++}
++
++print "Can't find your catalog ($cat) in director configuration\n";
++exit 1;
+diff -Naur bacula-2.4.4.old/src/cats/Makefile.in bacula-2.4.4/src/cats/Makefile.in
+--- bacula-2.4.4.old/src/cats/Makefile.in 2012-07-26 16:34:45.147962230 +0200
++++ bacula-2.4.4/src/cats/Makefile.in 2012-07-26 16:36:57.566562086 +0200
+@@ -87,7 +87,7 @@
+ $(RMF) grant_sqlite3_privileges drop_sqlite3_tables drop_sqlite3_database
+
+ $(RMF) mysql sqlite postgresql
+- $(RMF) make_catalog_backup delete_catalog_backup
++ $(RMF) make_catalog_backup.pl delete_catalog_backup
+
+ distclean: realclean
+ if test $(srcdir) = .; then $(MAKE) realclean; fi
+@@ -112,7 +112,7 @@
+ $(INSTALL_SCRIPT) drop_bacula_tables $(DESTDIR)$(scriptdir)/drop_bacula_tables
+ $(INSTALL_SCRIPT) drop_bacula_database $(DESTDIR)$(scriptdir)/drop_bacula_database
+
+- @filename=make_catalog_backup; \
++ @filename=make_catalog_backup.pl; \
+ if test -f ${DESTDIR}${scriptdir}/$$filename; then \
+ destname=$$filename.new; \
+ echo " ==> Found existing $$filename, installing new file as $$destname"; \
+@@ -146,7 +146,7 @@
+ (cd $(DESTDIR)$(scriptdir); $(RMF) drop_bacula_tables)
+ (cd $(DESTDIR)$(scriptdir); $(RMF) drop_bacula_database)
+
+- (cd $(DESTDIR)$(scriptdir); $(RMF) make_catalog_backup)
++ (cd $(DESTDIR)$(scriptdir); $(RMF) make_catalog_backup.pl)
+ (cd $(DESTDIR)$(scriptdir); $(RMF) delete_catalog_backup)
+
+
+diff -Naur bacula-2.4.4.old/src/dird/bacula-dir.conf.in bacula-2.4.4/src/dird/bacula-dir.conf.in
+--- bacula-2.4.4.old/src/dird/bacula-dir.conf.in 2012-07-26 16:34:45.151962306 +0200
++++ bacula-2.4.4/src/dird/bacula-dir.conf.in 2012-07-26 16:40:35.186837846 +0200
+@@ -61,11 +61,9 @@
+ FileSet="Catalog"
+ Schedule = "WeeklyCycleAfterBackup"
+ # This creates an ASCII copy of the catalog
+- # WARNING!!! Passing the password via the command line is insecure.
+- # see comments in make_catalog_backup for details.
+- # Arguments to make_catalog_backup are:
+- # make_catalog_backup <database-name> <user-name> <password> <host>
+- RunBeforeJob = "@scriptdir@/make_catalog_backup @db_name@ @db_user@"
++ # Arguments to make_catalog_backup.pl are:
++ # make_catalog_backup.pl <catalog-name>
++ RunBeforeJob = "@scriptdir@/make_catalog_backup.pl MyCatalog"
+ # This deletes the copy of the catalog
+ RunAfterJob = "@scriptdir@/delete_catalog_backup"
+ Write Bootstrap = "@working_dir@/BackupCatalog.bsr"
More information about the scm-commits
mailing list