Hi all
This is my first try on restoring piped dumps from postgres as created by http://wiki.bacula.org/doku.php?id=application_specific_backups:postgresql Well is i said in my last message when you try restoring those backups you merely get fifos!! so i wondered if should be posible create a listening process on the fifo prior to restoring... So The wiki job for bakups.. Job { Name = "PostgreSQL Backup" JobDefs = "DefaultJob" Level = Full FileSet="quasar-postgres" Client = quasar-fd Pool = FILESRV02 Schedule = "WeeklyCycleAfterBackup" # This creates a backup of the databases with pg_dump to fifos Client Run Before Job = "su - postgres -c \"/etc/bacula/postgres/bacula_make_database_backup.sh\"" # This deletes the backup and fifo files Client Run After Job = "su - postgres -c \"/etc/bacula/postgres/bacula_delete_database_backup.sh\"" Priority = 17 # run after main backup } is completed with a new restore job Job { Name = "PostgreSQL Restore" Type = Restore Client = quasar-fd # Just let void or put your info here FileSet="quasar-postgres" # Just let void or put your info here Level = Full Pool = FILESRV02 # Just let void or put your info here # This creates a restore to fifos Client Run Before Job = "su - postgres -c \"/etc/bacula/postgres/bacula_make_database_restore.sh\"" # This deletes the restored fifo files Client Run After Job = "su - postgres -c \"/etc/bacula/postgres/bacula_delete_database_restore.sh\"" Messages = Standard Where = / Priority = 17 # run after main backup } thats create reading proceses on hte fifos waiting for data to come in... #################################################### /etc/bacula/postgres/bacula_make_database_restore.sh: #!/bin/sh exec > /dev/null DUMPDIR=/var/lib/pgsql/data/dump FIFODIR=$DUMPDIR/fifo export PGUSER=postgres #export PGPASSWORD=xxxx # only when pg_hba.conf requires it rm -f $FIFODIR/*.data.dump for dbname in `psql -d template1 -q -t <<EOF select datname from pg_database where not datname in ('bacula','template0') order by datname; EOF ` do mkfifo $FIFODIR/$dbname.schema.dump /bin/dd if="$FIFODIR/$dbname.schema.dump" of="$FIFODIR/$dbname.schema.custom" 2>&1 < /dev/null & mkfifo $FIFODIR/$dbname.data.dump /bin/dd if="$FIFODIR/$dbname.data.dump" of="$FIFODIR/$dbname.data.custom" 2>&1 < /dev/null & done and a post resore job that clean things up.. ###################################################### /etc/bacula/postgres/bacula_delete_database_restore.sh: #!/bin/sh DUMPDIR=/var/lib/pgsql/data/dump FIFODIR=$DUMPDIR/fifo for dbname in `psql -U postgres -d template1 -q -t <<EOF select datname from pg_database where not datname in ('bacula','template0') order by datname; EOF ` do kill `ps aux | fgrep "dd" | fgrep " $dbname.schema.dump" | awk '{print $2}'` rm -f $FIFODIR/$dbname.schema.dump kill `ps aux | fgrep "dd" | fgrep " $dbname.data.dump" | awk '{print $2}'` rm -f $FIFODIR/$dbname.data.dump done rm -f $DUMPDIR/globalobjects.dump As im testing this, i just changed the restoring pg_dump for a not so dangerous dd to extract to disk data comeing from the pipes. YMMV but ive just backed up my postgres databases and later i managed to restore only the single file contaning schemas from one of the databases succesfully. once again i marked another file in the backup (shoed as fifos with 0 bytes) and my data came up without trouble... Ive attached all the files, please don hesitate contact on any question. Anyone with proper permissions, please upload this to wiki. Regards Angel -- No imprima este correo si no es necesario. El medio ambiente está en nuestras manos. ->>----------------------------------------------- Clist UAH a.k.a Angel ---------------------------------[www.uah.es]-<<-- MySQL3: Bueno, realmente ¿para que necesitas transacciones?
postgres.tar
Description: Unix tar archive
------------------------------------------------------------------------------
_______________________________________________ Bacula-users mailing list Bacula-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bacula-users