In Ubuntu AMD64, I prefer to use a script that backup all my postgres databases 
at once. I have an excellent script (not mine :p) that I launch every day with 
the user postgres through crontab.
I can have daily backup over 30 days of all databases and 1 monthly backup 
stored in a directory. Of course periodicity can be tweaked...

#!/bin/sh
#
# Postgresql backup script
#
# Author
#  |
#  +-- speedboy (speedboy_420 at hotmail dot com)
#  +-- spiderr (spiderr at bitweaver dot org)
#
# Last modified
#  |
#  +-- 16-10-2001
#  +-- 16-12-2007
#
# Version
#  |
#  +-- 1.1.2
#
# Description
#  |
#  +-- A bourne shell script that automates the backup, vacuum and
#      analyze of databases running on a postgresql server.
#
# Tested on
#  |
#  +-- Postgresql
#  |    |
#  |    +-- 8.1.9
#  |    +-- 7.1.3
#  |    +-- 7.1.2
#  |    +-- 7.1
#  |    +-- 7.0
#  |
#  +-- Operating systems
#  |    |
#  |    +-- CentOS 5 (RHEL 5)
#  |    +-- Linux Redhat 6.2
#  |    +-- Linux Mandrake 7.2
#  |    +-- FreeBSD 4.3
#  |    +-- Cygwin (omit the column ":" because NT 
doesn't quite digest it)
#  |
#  +-- Shells:
#       |
#       +-- sh
#       +-- bash
#       +-- ksh
#
# Requirements
#  |
#  +-- grep, awk, sed, echo, bzip2, chmod, touch, mkdir, date, psql,
#      test, expr, dirname, find, tail, du, pg_dump, vacuum_db
#
# Installation
#  |
#  +-- Set the path and shell you wish to use for this script on the
#  |   first line of this file. Keep in mind this script has 
only been
#  |   tested on the shells above in the "Tested on" section.
#  |
#  +-- Set the configuration variables below in the configuration
#  |   section to appropriate values.
#  |
#  +-- Remove the line at the end of the configuration section so that
#  |   the script will run.
#  |
#  +-- Now save the script and perform the following command:
#  |
#  |   chmod +x ./pg_backup.sh
#  |
#  +-- Now run the configuration test:
#  |
#  |   ./pg_backup.sh configtest
#  |
#  |   This will test the configuration details.
#  |
#  +-- Once you have done that add similiar entries given as examples
#      below to the crontab (`crontab -e`) without the 
the _first_ #
#      characters.
#
#      # Run a backup of the remote database host 'foodb', 
likely on a private network
#      00 03 * * * export PGHOST=foodb; export 
PGBACKUPDIR=/bak/backups ; nice /server/postgres/pg_backup.sh b 2  >> 
/var/log/pgsql/pg_backup.log 2>&1
#      # Run a backup of the local database host 'foodb' to a 
custom backup directory
#      00 04 * * * export PGBACKUPDIR=/bak/backups ; nice 
/usr/bin/pg_backup b 2  >> /var/log/pgsql/pg_backup.log 2>&1
#
# Restoration
#  |
#  +-- Restoration can be performed by using psql or pg_restore.
#  |   Here are two examples:
#  |
#  |   a) If the backup is plain text:
#  |
#  |   Firstly bunzip2 your backup file (if it was 
bzip2ped).
#  |
#  |   nunzip2 backup_file.bz2
#&nbsp; |&nbsp; &nbsp;psql -U postgres database < backup_file
#&nbsp; |
#&nbsp; |&nbsp; &nbsp;b&#41; If the backup is not plain text&#58;
#&nbsp; |
#&nbsp; |&nbsp; &nbsp;Firstly bunzip2 your backup file &#40;if it was 
bzip2ed&#41;.
#&nbsp; |
#&nbsp; |&nbsp; &nbsp;bunzip2 backup_file
#&nbsp; |&nbsp; &nbsp;pg_restore -d database -F &#123;c|t&#125; backup_file
#&nbsp; |
#&nbsp; |&nbsp; &nbsp;Note&#58; &#123;c|t&#125; is the format the database was 
backed up as.
#&nbsp; |
#&nbsp; |&nbsp; &nbsp;pg_restore -d database -F t backup_file_tar$PARAM_PGHOST
#&nbsp; |
#&nbsp; +-- Refer to the following url for more pg_restore help&#58;
#
#&nbsp; &nbsp; &nbsp; 
http&#58;//www.postgresql.org/idocs/index.php?app-pgrestore.html
#
# To Do List
#&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1. db_connectivity&#40;&#41; 
is BROKEN, if the script can not create a
#&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;connection to 
postmaster it should die and write to the logfile
#&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;that it could 
not connect.
#&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2. make configtest check for 
every required binary
#
########################################################################
#&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; Start configuration&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#
########################################################################
#
##################
# Authentication #
##################
#
# Postgresql hostname to connect to.
if &#91; $PGHOST &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; PARAM_PGHOST="-h $PGHOST"
else
&nbsp; &nbsp; &nbsp; &nbsp; PGHOST="pg-server"
fi
&nbsp;
# Postgresql username to perform backups under.
if &#91; -z $PGUSER &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; PGUSER="postgres"
fi
&nbsp;
# Postgresql password for the Postgresql username &#40;if required&#41;.
#postgresql_password="password"
&nbsp;
##################
# Locations&nbsp; &nbsp; &nbsp; #
##################
#
# Location to place backups.
if &#91; -z $PGBACKUPDIR &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; PGBACKUPDIR="/media/lenovo/pg_backup"
fi
subdir=`date +%Y-%m`
&nbsp;
# Location to place the pg_backup.sh logfile.
if &#91; -z $PGLOGDIR &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; PGLOGDIR="/var/log/postgresql/pg_backup.log"
fi
&nbsp;
# Location of the psql binaries.
if &#91; -z $PGBINDIR &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; PGBINDIR="/usr/bin"
fi
&nbsp;
##################
# Permissions&nbsp; &nbsp; #
##################
#
# Permissions for the backup location.
permissions_backup_dir="0755"
&nbsp;
# Permissions for the backup files.
permissions_backup_file="0644"
&nbsp;
# Permissions for the backup logfile.
permissions_backup_log="0644"
&nbsp;
##################
# Other options&nbsp; #
##################
#
# Databases to exclude from the backup process &#40;separated by a space&#41;
&nbsp; &nbsp; &nbsp; &nbsp; exclusions="template"
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Backup format
&nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; |
&nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; +-- p = plain text &#58; psql database < 
backup_file
&nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; +-- t = tar&nbsp; &nbsp; &nbsp; &nbsp; 
&#58; pg_restore -F t -d database backup_file
&nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; +-- c = custom&nbsp; &nbsp; &nbsp;&#58; 
pg_restore -F c -d database backup_file
&nbsp; &nbsp; &nbsp; &nbsp; #
&nbsp; &nbsp; &nbsp; &nbsp; backup_format="t"
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Backup large objects
&nbsp; &nbsp; &nbsp; &nbsp; backup_large_objects="yes"
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # bzip2 the backups
&nbsp; &nbsp; &nbsp; &nbsp; backup_bzip2="yes"
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Date format for the backup
&nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; |
&nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; +-- %d-%m-%Y&nbsp; &nbsp; &nbsp; &nbsp;= 
DD-MM-YYYY
&nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; +-- %Y-%m-%d&nbsp; &nbsp; &nbsp; &nbsp;= 
YYYY-MM-DD
&nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; +-- %A-%b-%Y&nbsp; &nbsp; &nbsp; &nbsp;= 
Tuesday-Sep-2001
&nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; +-- %A-%Y-%d-%m-%Y = Tuesday-2001-18-09-2001
&nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; |
&nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; +-- For more date formats type&#58;
&nbsp; &nbsp; &nbsp; &nbsp; #
&nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; &nbsp; &nbsp; date --help
&nbsp; &nbsp; &nbsp; &nbsp; #
&nbsp; &nbsp; &nbsp; &nbsp; backup_date_format="%Y-%m-%d"
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # You must comment out the line below before using 
this script
&nbsp; &nbsp; &nbsp; &nbsp; #echo "You must set all values in the configuration 
section in this file then run ./pg_backup.sh configtest before using this 
script" && exit 1
&nbsp; &nbsp; &nbsp; &nbsp; 
########################################################################
&nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End configuration&nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#
&nbsp; &nbsp; &nbsp; &nbsp; 
########################################################################
&nbsp; &nbsp; &nbsp; &nbsp; #
&nbsp; &nbsp; &nbsp; &nbsp; #################
&nbsp; &nbsp; &nbsp; &nbsp; # Variables&nbsp; &nbsp; &nbsp;#
&nbsp; &nbsp; &nbsp; &nbsp; #################
&nbsp; &nbsp; &nbsp; &nbsp; #
&nbsp; &nbsp; &nbsp; &nbsp; version="1.1.2"
&nbsp; &nbsp; &nbsp; &nbsp; current_time=`date +%H%M`
&nbsp; &nbsp; &nbsp; &nbsp; date_info=`date +$backup_date_format`
&nbsp; &nbsp; &nbsp; &nbsp; PGPASSWORD="$postgresql_password"
&nbsp; &nbsp; &nbsp; &nbsp; PATH="$PATH&#58;/bin&#58;/usr/bin"
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Export the variables
&nbsp; &nbsp; &nbsp; &nbsp; export PGUSER PGPASSWORD PATH
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; #################
&nbsp; &nbsp; &nbsp; &nbsp; # Checking&nbsp; &nbsp; &nbsp; #
&nbsp; &nbsp; &nbsp; &nbsp; #################
&nbsp; &nbsp; &nbsp; &nbsp; #
&nbsp; &nbsp; &nbsp; &nbsp; # Check the backup format
&nbsp; &nbsp; &nbsp; &nbsp; if &#91; "$backup_format" = "p" &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; backup_type="Plain text 
SQL"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; backup_args="-F 
$backup_format"
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; elif &#91; "$backup_format" = "t" &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; backup_type="Tar"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &#91; 
"$backup_large_objects" = "yes" &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; backup_args="-b -F $backup_format"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; backup_args="-F $backup_format"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fi
&nbsp; &nbsp; &nbsp; &nbsp; elif &#91; "$backup_format" = "c" &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; backup_type="Custom"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &#91; 
"$backup_large_objects" = "yes" &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; backup_args="-b -F $backup_format"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; backup_args="-F $backup_format"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fi
&nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; backup_format="c"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; backup_args="-F 
$backup_format"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; backup_type="Custom"
&nbsp; &nbsp; &nbsp; &nbsp; fi
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; #################
&nbsp; &nbsp; &nbsp; &nbsp; # Functions&nbsp; &nbsp; &nbsp;#
&nbsp; &nbsp; &nbsp; &nbsp; #################
&nbsp; &nbsp; &nbsp; &nbsp; #
&nbsp; &nbsp; &nbsp; &nbsp; # Obtain a list of available databases with 
reference to the user
&nbsp; &nbsp; &nbsp; &nbsp; # defined exclusions
db_connectivity&#40;&#41; &#123;
&nbsp; &nbsp; &nbsp; &nbsp; tmp=`echo "&#40;$exclusions&#41;" | sed 's/\ /\|/g'`
&nbsp; &nbsp; &nbsp; &nbsp; if &#91; "$exclusions" = "" &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
databases=`$PGBINDIR/psql $PARAM_PGHOST -U $PGUSER -q -c "\l" template1 | sed 
-n 4,/\eof/p | grep -v rows\&#41; | awk &#123;'print $1'&#125; || echo 
"Database connection could not be established at $timeinfo" >> $PGLOGDIR`
&nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
databases=`$PGBINDIR/psql $PARAM_PGHOST -U $PGUSER -q -c "\l" template1 | sed 
-n 4,/\eof/p | grep -v rows\&#41; | grep -Ev $tmp | awk &#123;'print $1'&#125; 
|| echo "Database connection could not be established at $timeinfo" >> 
$PGLOGDIR`
&nbsp; &nbsp; &nbsp; &nbsp; fi
&#125;
&nbsp;
# Setup the permissions according to the Permissions section
set_permissions&#40;&#41; &#123;
&nbsp; &nbsp; &nbsp; &nbsp; # Make the backup directories and secure them.
&nbsp; &nbsp; &nbsp; &nbsp; mkdir -m $permissions_backup_dir -p 
"$PGBACKUPDIR/$subdir"
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Touch the log file
&nbsp; &nbsp; &nbsp; &nbsp; touch "$PGLOGDIR"
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Make the backup tree
&nbsp; &nbsp; &nbsp; &nbsp; chmod -f $permissions_backup_log "$PGLOGDIR"
&nbsp; &nbsp; &nbsp; &nbsp; chmod -f $permissions_backup_dir "$PGBACKUPDIR"
&nbsp; &nbsp; &nbsp; &nbsp; chmod -f $permissions_backup_dir 
"$PGBACKUPDIR/$subdir"
#&nbsp; &nbsp; &nbsp; &nbsp;chmod -f $permissions_backup_dir 
"$PGBACKUPDIR/$subdir/$date_info"
&#125;
&nbsp;
# Run backup
run_b&#40;&#41; &#123;
&nbsp; &nbsp; &nbsp; &nbsp; for i in $databases; do
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start_time=`date '+%s'`
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; timeinfo=`date '+%T %x'`

&nbsp; &nbsp;&nbsp; &nbsp;if &#91; $&#40;date +%d&#41; = 1 &#93;;
&nbsp; &nbsp;&nbsp; &nbsp;then
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
&nbsp;OF="$PGBACKUPDIR/$subdir/$date_info-$current_time-pg_db-$PGHOST-$i.backup"
&nbsp; &nbsp;&nbsp; &nbsp;else
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;OF="$PGBACKUPDIR/$&#40;date 
+%d&#41;-pg_db-$PGHOST-$i.backup"
&nbsp; &nbsp;&nbsp; &nbsp;fi

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "$PGBINDIR/pg_dump" -i 
$backup_args $PARAM_PGHOST $i > "$OF"

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &#91; 
"$backup_bzip2" = "yes" &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; rm "$OF.bz2"
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;bzip2 "$OF"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; chmod $permissions_backup_file "$OF.bz2"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; chmod $permissions_backup_file "$OF"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fi

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; finish_time=`date '+%s'`
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; duration=`expr 
$finish_time - $start_time`
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Backup complete 
&#40;duration $duration seconds&#41; at $timeinfo for schedule $current_time on 
database&#58; $i, format&#58; $backup_type" >> $PGLOGDIR
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Backup File 
Name&#58; $OF" >> $PGLOGDIR
&nbsp; &nbsp; &nbsp; &nbsp; done
&nbsp; &nbsp; &nbsp; &nbsp; exit 1
&#125;
&nbsp;
# Run backup and vacuum
run_bv&#40;&#41; &#123;
&nbsp; &nbsp; &nbsp; &nbsp; for i in $databases; do
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start_time=`date '+%s'`
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; timeinfo=`date '+%T %x'`
&nbsp; &nbsp;&nbsp; &nbsp;if &#91; $&#40;date +%d&#41; = 1 &#93;;
&nbsp; &nbsp;&nbsp; &nbsp;then
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
&nbsp;OF="$PGBACKUPDIR/$subdir/$date_info-$current_time-pg_db-$PGHOST-$i.backup"
&nbsp; &nbsp;&nbsp; &nbsp;else
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;OF="$PGBACKUPDIR/$&#40;date 
+%d&#41;-pg_db-$PGHOST-$i.backup"
&nbsp; &nbsp;&nbsp; &nbsp;fi
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "$PGBINDIR/vacuumdb" 
$PARAM_PGHOST -U $PGUSER $i >/dev/null 2>&1
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "$PGBINDIR/pg_dump" -i 
$backup_args $PARAM_PGHOST $i > "$OF"

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &#91; 
"$backup_bzip2" = "yes" &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; rm "$OF.bz2"
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;bzip2 "$OF"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; chmod $permissions_backup_file "$OF.bz2"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; chmod $permissions_backup_file "$OF"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fi

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; finish_time=`date '+%s'`
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; duration=`expr 
$finish_time - $start_time`
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Backup and Vacuum 
complete &#40;duration $duration seconds&#41; at $timeinfo for schedule 
$current_time on database&#58; $i, format&#58; $backup_type" >> $PGLOGDIR
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Backup File 
Name&#58; $OF" >> $PGLOGDIR
&nbsp; &nbsp; &nbsp; &nbsp; done
&nbsp; &nbsp; &nbsp; &nbsp; exit 1&nbsp; &nbsp;
&#125;
&nbsp;
# Run backup, vacuum and analyze
run_bva&#40;&#41; &#123;
&nbsp; &nbsp; &nbsp; &nbsp; for i in $databases; do
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start_time=`date '+%s'`
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; timeinfo=`date '+%T %x'`
&nbsp; &nbsp;&nbsp; &nbsp;if &#91; $&#40;date +%d&#41; = 1 &#93;;
&nbsp; &nbsp;&nbsp; &nbsp;then
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
&nbsp;OF="$PGBACKUPDIR/$subdir/$date_info-$current_time-pg_db-$PGHOST-$i.backup"
&nbsp; &nbsp;&nbsp; &nbsp;else
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;OF="$PGBACKUPDIR/$&#40;date 
+%d&#41;-pg_db-$PGHOST-$i.backup"
&nbsp; &nbsp;&nbsp; &nbsp;fi
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "$PGBINDIR/vacuumdb" -z 
$PARAM_PGHOST -U $PGUSER $i >/dev/null 2>&1
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "$PGBINDIR/pg_dump" -i 
$backup_args $PARAM_PGHOST $i > "$OF"

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &#91; 
"$backup_bzip2" = "yes" &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; rm "$OF.bz2"
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;bzip2 "$OF"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; chmod $permissions_backup_file "$OF.bz2"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; chmod $permissions_backup_file "$OF"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fi

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; finish_time=`date '+%s'`
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; duration=`expr 
$finish_time - $start_time`
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Backup, Vacuum 
and Analyze complete &#40;duration $duration seconds&#41; at $timeinfo for 
schedule $current_time on database&#58; $i, format&#58; $backup_type" >> 
$PGLOGDIR
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Backup File 
Name&#58; $OF" >> $PGLOGDIR
&nbsp; &nbsp; &nbsp; &nbsp; done
&nbsp; &nbsp; &nbsp; &nbsp; exit 1
&#125;
&nbsp;
# Run vacuum
run_v&#40;&#41; &#123;
&nbsp; &nbsp; &nbsp; &nbsp; for i in $databases; do
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start_time=`date '+%s'`
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; timeinfo=`date '+%T %x'`
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "$PGBINDIR/vacuumdb" 
$PARAM_PGHOST -U $PGUSER $i >/dev/null 2>&1
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; finish_time=`date '+%s'`
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; duration=`expr 
$finish_time - $start_time`
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Vacuum complete 
&#40;duration $duration seconds&#41; at $timeinfo for schedule $current_time on 
database&#58; $i " >> $PGLOGDIR
&nbsp; &nbsp; &nbsp; &nbsp; done
&nbsp; &nbsp; &nbsp; &nbsp; exit 1
&#125;
&nbsp;
# Run vacuum and analyze
run_va&#40;&#41; &#123;
&nbsp; &nbsp; &nbsp; &nbsp; for i in $databases; do
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start_time=`date '+%s'`
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; timeinfo=`date '+%T %x'`
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "$PGBINDIR/vacuumdb" -z 
$PARAM_PGHOST -U $PGUSER $i >/dev/null 2>&1
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; finish_time=`date '+%s'`
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; duration=`expr 
$finish_time - $start_time`
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Vacuum and 
Analyze complete &#40;duration $duration seconds&#41; at $timeinfo for schedule 
$current_time on database&#58; $i " >> $PGLOGDIR
&nbsp; &nbsp; &nbsp; &nbsp; done
&nbsp; &nbsp; &nbsp; &nbsp; exit 1
&#125;
&nbsp;
# Print information regarding available backups
print_info&#40;&#41; &#123;
&nbsp; &nbsp; &nbsp; &nbsp; echo "Postgresql backup script version $version"
&nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp; &nbsp; &nbsp; &nbsp; echo "Available backups&#58;"
&nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp; &nbsp; &nbsp; &nbsp; if &#91; ! -d $PGBACKUPDIR &#93; ; then
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "There are 
currently no available backups"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit 0
&nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; for i in `find "$PGBACKUPDIR" -type d -maxdepth 2`; 
do
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "$i `du -h \"$i\" 
| tail -n 1 | awk &#123;'print $1'&#125;`"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #for j in `ls 
"$PGBACKUPDIR/$i"`; do
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #&nbsp; &nbsp; &nbsp; 
&nbsp;echo "&nbsp; &nbsp; $j `du -h \"$PGBACKUPDIR/$i/$j\" | tail -n 1 | awk 
&#123;'print $1'&#125;`"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #done
&nbsp; &nbsp; &nbsp; &nbsp; done
&nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp; &nbsp; &nbsp; &nbsp; fi
&nbsp; &nbsp; &nbsp; &nbsp; exit 1
&#125;
&nbsp;
# Print configuration test
print_configtest&#40;&#41; &#123;
&nbsp; &nbsp; &nbsp; &nbsp; echo "Postgresql backup script version $version"
&nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp; &nbsp; &nbsp; &nbsp; echo "Configuration test..."
&nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Check database connectivity information
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Database hostname&nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#58; "
&nbsp; &nbsp; &nbsp; &nbsp; echo "$PGHOST"
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Database username&nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#58; "
&nbsp; &nbsp; &nbsp; &nbsp; echo "$PGUSER"
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Database connectivity&nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#58; "
&nbsp; &nbsp; &nbsp; &nbsp; $PGBINDIR/psql $PARAM_PGHOST -U $PGUSER -q -c 
"select now&#40;&#41;" template1 > /dev/null 2>&1 && echo "Yes" || echo 
"Connection could not be established..."
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Backup information
&nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp; &nbsp; &nbsp; &nbsp; echo "Backup information&#58;"
&nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Backup format&nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#58; "
&nbsp; &nbsp; &nbsp; &nbsp; if &#91; "$backup_format" = "p" &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Plain text SQL"
&nbsp; &nbsp; &nbsp; &nbsp; elif &#91; "$backup_format" = "t" &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Tar"
&nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Custom"
&nbsp; &nbsp; &nbsp; &nbsp; fi
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Backup large objects&nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#58; "
&nbsp; &nbsp; &nbsp; &nbsp; if &#91; "$backup_large_objects" = "yes" &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Yes"
&nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "No"
&nbsp; &nbsp; &nbsp; &nbsp; fi
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "bzip2 backups&nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#58; "
&nbsp; &nbsp; &nbsp; &nbsp; if &#91; "$backup_bzip2" = "yes" &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Yes"
&nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "No"
&nbsp; &nbsp; &nbsp; &nbsp; fi
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Backup date format&nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#58; $date_info"
&nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # File locations
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Backup directory&nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#58; "
&nbsp; &nbsp; &nbsp; &nbsp; echo "$PGBACKUPDIR"
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Backup logfile&nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#58; "
&nbsp; &nbsp; &nbsp; &nbsp; echo "$PGLOGDIR"
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Postgresql binaries&nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#58; "
&nbsp; &nbsp; &nbsp; &nbsp; echo "$PGBINDIR"
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Backup file permissions
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Backup directory permissions&nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp;&#58; "
&nbsp; &nbsp; &nbsp; &nbsp; echo "$permissions_backup_dir"
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Backup file permissions&nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#58; "
&nbsp; &nbsp; &nbsp; &nbsp; echo "$permissions_backup_file"
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Backup log permissions&nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#58; "
&nbsp; &nbsp; &nbsp; &nbsp; echo "$permissions_backup_log"
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Databases that will be backed up
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Databases that will be backed up&nbsp; 
&nbsp; &nbsp;&#58; "
&nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp; &nbsp; &nbsp; &nbsp; for i in $databases; do
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "&nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$i"
&nbsp; &nbsp; &nbsp; &nbsp; done
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Databases that will not be backed up
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Databases that will not be backed up &#58;"
&nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp; &nbsp; &nbsp; &nbsp; if &#91; "$exclusions" = "" &#93;; then
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "&nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;none"
&nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for i in $exclusions; do
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; echo "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$i"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; done
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp; &nbsp; &nbsp; &nbsp; fi
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Check if the backups location is writable
&nbsp; &nbsp; &nbsp; &nbsp; echo "Checking permissions&#58;"
&nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Write access&nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#58; 
$PGBACKUPDIR&#58; "
&nbsp; &nbsp; &nbsp; &nbsp; # Needed to create/write to the dump location"
&nbsp; &nbsp; &nbsp; &nbsp; test -w "$PGBACKUPDIR" && echo "Yes" || echo "No"
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Check if the logfile location is writable
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Write access&nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#58; 
$PGLOGDIR&#58; "
&nbsp; &nbsp; &nbsp; &nbsp; # Needed to create/write to this scripts logfile"
&nbsp; &nbsp; &nbsp; &nbsp; if &#91; ! -x $PGLOGDIR &#93; ; then
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; test -w `dirname 
"$PGLOGDIR"` && echo "Yes" || echo "No"
&nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; test -w "$PGLOGDIR" && 
echo "Yes" || echo "No"
&nbsp; &nbsp; &nbsp; &nbsp; fi
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Check if the binaries are executable
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Execute access&nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#58; 
$PGBINDIR/psql&#58; "
&nbsp; &nbsp; &nbsp; &nbsp; test -x $PGBINDIR/psql && echo "Yes" || echo "No"
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Execute access&nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#58; 
$PGBINDIR/pg_dump&#58; "
&nbsp; &nbsp; &nbsp; &nbsp; test -x $PGBINDIR/pg_dump && echo "Yes" || echo "No"
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; echo -n "Execute access&nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#58; 
$PGBINDIR/vacuumdb&#58; "
&nbsp; &nbsp; &nbsp; &nbsp; test -x $PGBINDIR/vacuumdb && echo "Yes" || echo 
"No"
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp; &nbsp; &nbsp; &nbsp; exit 1
&#125;
&nbsp;
# Print help
print_help&#40;&#41; &#123;
&nbsp; &nbsp; &nbsp; &nbsp; echo "Postgresql backup script version $version"
&nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp; &nbsp; &nbsp; &nbsp; echo "Usage&#58; $0 &#91;options&#93;"
&nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp; &nbsp; &nbsp; &nbsp; echo "Options&#58;"
&nbsp; &nbsp; &nbsp; &nbsp; echo "&nbsp; b,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
Backup ALL databases"
&nbsp; &nbsp; &nbsp; &nbsp; echo "&nbsp; bv,&nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp;Backup and Vacuum ALL databases"
&nbsp; &nbsp; &nbsp; &nbsp; echo "&nbsp; bva,&nbsp; &nbsp; &nbsp; &nbsp; 
Backup, Vacuum and Analyze ALL databases"
&nbsp; &nbsp; &nbsp; &nbsp; echo "&nbsp; v,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
Vacuum ALL databases"
&nbsp; &nbsp; &nbsp; &nbsp; echo "&nbsp; va,&nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp;Vacuum and Analyze ALL databases"
&nbsp; &nbsp; &nbsp; &nbsp; echo "&nbsp; info,&nbsp; &nbsp; &nbsp; 
&nbsp;Information regarding all available backups"
&nbsp; &nbsp; &nbsp; &nbsp; echo "&nbsp; configtest, Configuration test"
&nbsp; &nbsp; &nbsp; &nbsp; echo "&nbsp; help,&nbsp; &nbsp; &nbsp; &nbsp;This 
message"
&nbsp; &nbsp; &nbsp; &nbsp; echo ""
&nbsp; &nbsp; &nbsp; &nbsp; echo "Report bugs to <speedboy_420 at hotmail dot 
com >."
&nbsp; &nbsp; &nbsp; &nbsp; exit 1
&#125;
&nbsp;
case "$1" in
&nbsp; &nbsp; &nbsp; &nbsp; # Run backup
&nbsp; &nbsp; &nbsp; &nbsp; b&#41;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db_connectivity
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set_permissions
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; run_b
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit 1
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;;
&nbsp; &nbsp; &nbsp; &nbsp; # Run backup and vacuum
&nbsp; &nbsp; &nbsp; &nbsp; bv&#41;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db_connectivity
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set_permissions
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; run_bv
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit 1
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;;
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Run backup, vacuum and analyze
&nbsp; &nbsp; &nbsp; &nbsp; bva&#41;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db_connectivity
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set_permissions
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; run_bva
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit 1
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;;
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Run vacuum
&nbsp; &nbsp; &nbsp; &nbsp; v&#41;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db_connectivity
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set_permissions
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; run_v
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit 1
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;;
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Run vacuum and analyze
&nbsp; &nbsp; &nbsp; &nbsp; va&#41;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db_connectivity
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set_permissions
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; run_va
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit 1
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;;
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Print info
&nbsp; &nbsp; &nbsp; &nbsp; info&#41;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set_permissions
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print_info
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit 1
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;;
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Print configtest
&nbsp; &nbsp; &nbsp; &nbsp; configtest&#41;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db_connectivity
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set_permissions
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print_configtest
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit 1
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;;
&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; # Default
&nbsp; &nbsp; &nbsp; &nbsp; *&#41;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print_help
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit 1
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;;
esac


Make sure the file is executable:
chmod +x pg_backup.sh
Create the log file :
touch&nbsp; /var/log/postgresql/pg_backup.log
chown postgres&nbsp; /var/log/postgresql/pg_backup.log

Here is example of crontab file (crontab.txt)
00 3 * * * sh /home/postgres/scripts/pg_backup.sh b 2&nbsp; >> 
/var/log/postgresql/pg_backup.log 2>&1


Launch crontab with postgres user:
sudo su postgres
Enter password
crontab crontab.txt

Hope this help

Eric




-------------------- m2f --------------------

--
http://www.openobject.com/forum/viewtopic.php?p=54434#54434

-------------------- m2f --------------------


_______________________________________________
Tinyerp-users mailing list
http://tiny.be/mailman2/listinfo/tinyerp-users

Reply via email to