Re: [seapug] Re: [BUGS] pg_dump: aborting because of server version mismatchT

Lists: adelaide-au-pugatlpugaustinpugbostonpugbwpugpgsql-adminpgsql-bugspgsql-sqlseapugsfpug
From: Mitesh Shah <mitesh(dot)shah(at)stripes39(dot)com>
To: pgsql-admin(at)postgresql(dot)org, pgsql-bugs(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org, adelaide-au-pug(at)postgresql(dot)org, seapug(at)postgresql(dot)org
Subject: pg_dump: aborting because of server version mismatch
Date: 2012-05-02 19:55:58
Message-ID: CAHofYQQ6yvHGCiHPBqTAL5fU=3haWXdE7oX-3=q=pcGYPajFxg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: adelaide-au-pug atlpug austinpug bostonpug bwpug pgsql-admin pgsql-bugs pgsql-sql seapug sfpug

Hi,
I am trying to create a daily backup cron script but it fails with an error
as below:

Any pointers to resolve this will be greatly appreciated.

Thanks,
Mitesh Shah
mitesh(dot)shah(at)stripes39(dot)com

*(1) Error:*
bash-3.2$ sh pg_backup_rotated_orig.sh
Making backup directory in /Users/miteshshah/Documents/2012-05-02-daily/
-e

Performing full backups
-e --------------------------------------------

Plain backup of mitesh
*pg_dump: server version: 9.1.2; pg_dump version: 9.0.5*
*pg_dump: aborting because of server version mismatch*
-e
All database backups complete!

*(2.1) * /Users/miteshshah/Desktop/*pg_backup.config file:*
#############################
## POSTGRESQL BACKUP CONFIG ##
##############################
# hostname to adhere to pg_hba policies.
HOSTNAME= <host>

# username to connect to database as.
USERNAME=<user>

# Database name
DATABASE=<database>

# This dir will be created if it doesn't exist. This must be writable by
the user the script is
# running as.
BACKUP_DIR=<backup_dir>

# SCRIPTPATH
SCRIPTPATH=<path>

# Will produce a custom-format backup if set to "yes"
ENABLE_CUSTOM_BACKUPS=yes

# Will produce a gzipped plain-format backup if set to "yes"
ENABLE_PLAIN_BACKUPS=yes

#### SETTINGS FOR ROTATED BACKUPS ####

# Which day to take the weekly backup from (1-7 = Monday-Sunday)
DAY_OF_WEEK_TO_KEEP=5

# Number of days to keep daily backups
DAYS_TO_KEEP=7

# How many weeks to keep weekly backups
WEEKS_TO_KEEP=5

######################################

*(2.2) * /Users/miteshshah/Desktop/*pg_backup_rotated_orig.sh*
#!/bin/bash

###########################
####### LOAD CONFIG #######
###########################

source /Users/miteshshah/Desktop/pg_backup.config

###########################
#### START THE BACKUPS ####
###########################

function perform_backups()
{
SUFFIX=$1
FINAL_BACKUP_DIR=$BACKUP_DIR"`date +\%Y-\%m-\%d`$SUFFIX/"

echo "Making backup directory in $FINAL_BACKUP_DIR"

if ! mkdir -p $FINAL_BACKUP_DIR; then
echo "Cannot create backup directory in $FINAL_BACKUP_DIR.
Go and fix it!"
exit 1;
fi;

###########################
###### FULL BACKUPS #######
###########################

echo -e "\n\nPerforming full backups"
echo -e "--------------------------------------------\n"

if [ $ENABLE_PLAIN_BACKUPS = "yes" ]
then
echo "Plain backup of $DATABASE"

if ! pg_dump -Fp -h "$HOSTNAME" -U "$USERNAME"
"$DATABASE" | gzip > $FINAL_BACKUP_DIR"$DATABASE".sql.gz.in_progress; then
echo "[!!ERROR!!] Failed to produce plain
backup database $DATABASE"
else
mv
$FINAL_BACKUP_DIR"$DATABASE".sql.gz.in_progress
$FINAL_BACKUP_DIR"$DATABASE".sql.gz
fi
fi

if [ $ENABLE_CUSTOM_BACKUPS = "yes" ]
then
echo "Custom backup of $DATABASE"

if ! pg_dump -Fc -h "$HOSTNAME" -U "$USERNAME"
"$DATABASE" -f $FINAL_BACKUP_DIR"$DATABASE".custom.in_progress; then
echo "[!!ERROR!!] Failed to produce custom
backup database $DATABASE"
else
mv
$FINAL_BACKUP_DIR"$DATABASE".custom.in_progress
$FINAL_BACKUP_DIR"$DATABASE".custom
fi
fi

echo -e "\nAll database backups complete!"
}

# DAILY BACKUPS

# Delete daily backups 7 days old or more
find $BACKUP_DIR -maxdepth 1 -mtime +$DAYS_TO_KEEP -name "*-daily" -exec rm
-rf '{}' ';'


From: Mitesh Shah <mitesh(dot)shah(at)stripes39(dot)com>
To: sfpug(at)postgresql(dot)org, atlpug(at)postgresql(dot)org, austinpug(at)postgresql(dot)org, bostonpug(at)postgresql(dot)org, bwpug(at)postgresql(dot)org
Subject: pg_dump: aborting because of server version mismatch
Date: 2012-05-02 19:58:07
Message-ID: CAHofYQQOmZKT2Y=kUV0_GLgT59vjj8UBa5ShR0yHxyZYsGQd0w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: adelaide-au-pug atlpug austinpug bostonpug bwpug pgsql-admin pgsql-bugs pgsql-sql seapug sfpug

Hi,
I am trying to create a daily backup cron script but it fails with an error
as below:

Any pointers to resolve this will be greatly appreciated.

Thanks,
Mitesh Shah
mitesh(dot)shah(at)stripes39(dot)com

*(1) Error:*
bash-3.2$ sh pg_backup_rotated_orig.sh
Making backup directory in /Users/miteshshah/Documents/2012-05-02-daily/
-e

Performing full backups
-e --------------------------------------------

Plain backup of mitesh
*pg_dump: server version: 9.1.2; pg_dump version: 9.0.5*
*pg_dump: aborting because of server version mismatch*
-e
All database backups complete!

*(2.1) * /Users/miteshshah/Desktop/*pg_backup.config file:*
#############################
## POSTGRESQL BACKUP CONFIG ##
##############################
# hostname to adhere to pg_hba policies.
HOSTNAME= <host>

# username to connect to database as.
USERNAME=<user>

# Database name
DATABASE=<database>

# This dir will be created if it doesn't exist. This must be writable by
the user the script is
# running as.
BACKUP_DIR=<backup_dir>

# SCRIPTPATH
SCRIPTPATH=<path>

# Will produce a custom-format backup if set to "yes"
ENABLE_CUSTOM_BACKUPS=yes

# Will produce a gzipped plain-format backup if set to "yes"
ENABLE_PLAIN_BACKUPS=yes

#### SETTINGS FOR ROTATED BACKUPS ####

# Which day to take the weekly backup from (1-7 = Monday-Sunday)
DAY_OF_WEEK_TO_KEEP=5

# Number of days to keep daily backups
DAYS_TO_KEEP=7

# How many weeks to keep weekly backups
WEEKS_TO_KEEP=5

######################################

*(2.2) * /Users/miteshshah/Desktop/*pg_backup_rotated_orig.sh*
#!/bin/bash

###########################
####### LOAD CONFIG #######
###########################

source /Users/miteshshah/Desktop/pg_backup.config

###########################
#### START THE BACKUPS ####
###########################

function perform_backups()
{
SUFFIX=$1
FINAL_BACKUP_DIR=$BACKUP_DIR"`date +\%Y-\%m-\%d`$SUFFIX/"

echo "Making backup directory in $FINAL_BACKUP_DIR"

if ! mkdir -p $FINAL_BACKUP_DIR; then
echo "Cannot create backup directory in $FINAL_BACKUP_DIR.
Go and fix it!"
exit 1;
fi;

###########################
###### FULL BACKUPS #######
###########################

echo -e "\n\nPerforming full backups"
echo -e "--------------------------------------------\n"

if [ $ENABLE_PLAIN_BACKUPS = "yes" ]
then
echo "Plain backup of $DATABASE"

if ! pg_dump -Fp -h "$HOSTNAME" -U "$USERNAME"
"$DATABASE" | gzip > $FINAL_BACKUP_DIR"$DATABASE".sql.gz.in_progress; then
echo "[!!ERROR!!] Failed to produce plain
backup database $DATABASE"
else
mv
$FINAL_BACKUP_DIR"$DATABASE".sql.gz.in_progress
$FINAL_BACKUP_DIR"$DATABASE".sql.gz
fi
fi

if [ $ENABLE_CUSTOM_BACKUPS = "yes" ]
then
echo "Custom backup of $DATABASE"

if ! pg_dump -Fc -h "$HOSTNAME" -U "$USERNAME"
"$DATABASE" -f $FINAL_BACKUP_DIR"$DATABASE".custom.in_progress; then
echo "[!!ERROR!!] Failed to produce custom
backup database $DATABASE"
else
mv
$FINAL_BACKUP_DIR"$DATABASE".custom.in_progress
$FINAL_BACKUP_DIR"$DATABASE".custom
fi
fi

echo -e "\nAll database backups complete!"
}

# DAILY BACKUPS

# Delete daily backups 7 days old or more
find $BACKUP_DIR -maxdepth 1 -mtime +$DAYS_TO_KEEP -name "*-daily" -exec rm
-rf '{}' ';'


From: Mitesh Shah <mitesh(dot)shah(at)stripes39(dot)com>
To: seapug(at)postgresql(dot)org
Subject: pg_dump: aborting because of server version mismatch
Date: 2012-05-02 20:23:58
Message-ID: CAHofYQRT-WXgD-+nojF_UNqjnT+Oubf+uY542dS_-m+2ib7g+w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: adelaide-au-pug atlpug austinpug bostonpug bwpug pgsql-admin pgsql-bugs pgsql-sql seapug sfpug

Hi,
I am trying to create a daily backup cron script but it fails with an error
as below:

Any pointers to resolve this will be greatly appreciated.

Thanks,
Mitesh Shah
mitesh(dot)shah(at)stripes39(dot)com

*(1) Error:*
bash-3.2$ sh pg_backup_rotated_orig.sh
Making backup directory in /Users/miteshshah/Documents/2012-05-02-daily/
-e

Performing full backups
-e --------------------------------------------

Plain backup of mitesh
*pg_dump: server version: 9.1.2; pg_dump version: 9.0.5*
*pg_dump: aborting because of server version mismatch*
-e
All database backups complete!

*(2.1) * /Users/miteshshah/Desktop/*pg_backup.config file:*
#############################
## POSTGRESQL BACKUP CONFIG ##
##############################
# hostname to adhere to pg_hba policies.
HOSTNAME= <host>

# username to connect to database as.
USERNAME=<user>

# Database name
DATABASE=<database>

# This dir will be created if it doesn't exist. This must be writable by
the user the script is
# running as.
BACKUP_DIR=<backup_dir>

# SCRIPTPATH
SCRIPTPATH=<path>

# Will produce a custom-format backup if set to "yes"
ENABLE_CUSTOM_BACKUPS=yes

# Will produce a gzipped plain-format backup if set to "yes"
ENABLE_PLAIN_BACKUPS=yes

#### SETTINGS FOR ROTATED BACKUPS ####

# Which day to take the weekly backup from (1-7 = Monday-Sunday)
DAY_OF_WEEK_TO_KEEP=5

# Number of days to keep daily backups
DAYS_TO_KEEP=7

# How many weeks to keep weekly backups
WEEKS_TO_KEEP=5

######################################

*(2.2) * /Users/miteshshah/Desktop/*pg_backup_rotated_orig.sh*
#!/bin/bash

###########################
####### LOAD CONFIG #######
###########################

source /Users/miteshshah/Desktop/pg_backup.config

###########################
#### START THE BACKUPS ####
###########################

function perform_backups()
{
SUFFIX=$1
FINAL_BACKUP_DIR=$BACKUP_DIR"`date +\%Y-\%m-\%d`$SUFFIX/"

echo "Making backup directory in $FINAL_BACKUP_DIR"

if ! mkdir -p $FINAL_BACKUP_DIR; then
echo "Cannot create backup directory in $FINAL_BACKUP_DIR.
Go and fix it!"
exit 1;
fi;

###########################
###### FULL BACKUPS #######
###########################

echo -e "\n\nPerforming full backups"
echo -e "--------------------------------------------\n"

if [ $ENABLE_PLAIN_BACKUPS = "yes" ]
then
echo "Plain backup of $DATABASE"

if ! pg_dump -Fp -h "$HOSTNAME" -U "$USERNAME"
"$DATABASE" | gzip > $FINAL_BACKUP_DIR"$DATABASE".sql.gz.in_progress; then
echo "[!!ERROR!!] Failed to produce plain
backup database $DATABASE"
else
mv
$FINAL_BACKUP_DIR"$DATABASE".sql.gz.in_progress
$FINAL_BACKUP_DIR"$DATABASE".sql.gz
fi
fi

if [ $ENABLE_CUSTOM_BACKUPS = "yes" ]
then
echo "Custom backup of $DATABASE"

if ! pg_dump -Fc -h "$HOSTNAME" -U "$USERNAME"
"$DATABASE" -f $FINAL_BACKUP_DIR"$DATABASE".custom.in_progress; then
echo "[!!ERROR!!] Failed to produce custom
backup database $DATABASE"
else
mv
$FINAL_BACKUP_DIR"$DATABASE".custom.in_progress
$FINAL_BACKUP_DIR"$DATABASE".custom
fi
fi

echo -e "\nAll database backups complete!"
}

# DAILY BACKUPS

# Delete daily backups 7 days old or more
find $BACKUP_DIR -maxdepth 1 -mtime +$DAYS_TO_KEEP -name "*-daily" -exec rm
-rf '{}' ';'


From: "Albin, Lloyd P" <lalbin(at)scharp(dot)org>
To: Mitesh Shah <mitesh(dot)shah(at)stripes39(dot)com>, <seapug(at)postgresql(dot)org>
Subject: Re: pg_dump: aborting because of server version mismatch
Date: 2012-05-02 21:01:47
Message-ID: D780EAC3ADA31F488BCA74ECCD5B717E0A78CDE6@ISIS.fhcrc.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: adelaide-au-pug atlpug austinpug bostonpug bwpug pgsql-admin pgsql-bugs pgsql-sql seapug sfpug

Mitesh,

Your server is newer than your pg_dump program. pg_dump must be the same
version as server version. You need to upgrade your pg_dump to be
version 9.1.2. It should have installed that version when you
installed/upgraded your Postgres version but may have been installed in
a different location or the one you are using for your script is not the
one that came with your server (separate install). So all you need to do
in your script is to point to the one that comes with the server and it
will work or update the one that you are currently using in the script
to version 9.1.2.

Lloyd

From: seapug-owner(at)postgresql(dot)org [mailto:seapug-owner(at)postgresql(dot)org]
On Behalf Of Mitesh Shah
Sent: Wednesday, May 02, 2012 1:24 PM
To: seapug(at)postgresql(dot)org
Subject: [seapug] pg_dump: aborting because of server version mismatch

Hi,

I am trying to create a daily backup cron script but it fails with an
error as below:

Any pointers to resolve this will be greatly appreciated.

Thanks,

Mitesh Shah

mitesh(dot)shah(at)stripes39(dot)com

(1) Error:

bash-3.2$ sh pg_backup_rotated_orig.sh

Making backup directory in /Users/miteshshah/Documents/2012-05-02-daily/

-e

Performing full backups

-e --------------------------------------------

Plain backup of mitesh

pg_dump: server version: 9.1.2; pg_dump version: 9.0.5

pg_dump: aborting because of server version mismatch

-e

All database backups complete!

(2.1) /Users/miteshshah/Desktop/pg_backup.config file:

#############################

## POSTGRESQL BACKUP CONFIG ##

##############################

# hostname to adhere to pg_hba policies.

HOSTNAME= <host>

# username to connect to database as.

USERNAME=<user>

# Database name

DATABASE=<database>

# This dir will be created if it doesn't exist. This must be writable
by the user the script is

# running as.

BACKUP_DIR=<backup_dir>

# SCRIPTPATH

SCRIPTPATH=<path>

# Will produce a custom-format backup if set to "yes"

ENABLE_CUSTOM_BACKUPS=yes

# Will produce a gzipped plain-format backup if set to "yes"

ENABLE_PLAIN_BACKUPS=yes

#### SETTINGS FOR ROTATED BACKUPS ####

# Which day to take the weekly backup from (1-7 = Monday-Sunday)

DAY_OF_WEEK_TO_KEEP=5

# Number of days to keep daily backups

DAYS_TO_KEEP=7

# How many weeks to keep weekly backups

WEEKS_TO_KEEP=5

######################################

(2.2) /Users/miteshshah/Desktop/pg_backup_rotated_orig.sh

#!/bin/bash

###########################

####### LOAD CONFIG #######

###########################

source /Users/miteshshah/Desktop/pg_backup.config

###########################

#### START THE BACKUPS ####

###########################

function perform_backups()

{

SUFFIX=$1

FINAL_BACKUP_DIR=$BACKUP_DIR"`date +\%Y-\%m-\%d`$SUFFIX/"

echo "Making backup directory in $FINAL_BACKUP_DIR"

if ! mkdir -p $FINAL_BACKUP_DIR; then

echo "Cannot create backup directory in
$FINAL_BACKUP_DIR. Go and fix it!"

exit 1;

fi;

###########################

###### FULL BACKUPS #######

###########################

echo -e "\n\nPerforming full backups"

echo -e "--------------------------------------------\n"

if [ $ENABLE_PLAIN_BACKUPS = "yes" ]

then

echo "Plain backup of $DATABASE"

if ! pg_dump -Fp -h "$HOSTNAME" -U "$USERNAME"
"$DATABASE" | gzip > $FINAL_BACKUP_DIR"$DATABASE".sql.gz.in_progress;
then

echo "[!!ERROR!!] Failed to produce
plain backup database $DATABASE"

else

mv
$FINAL_BACKUP_DIR"$DATABASE".sql.gz.in_progress
$FINAL_BACKUP_DIR"$DATABASE".sql.gz

fi

fi

if [ $ENABLE_CUSTOM_BACKUPS = "yes" ]

then

echo "Custom backup of $DATABASE"

if ! pg_dump -Fc -h "$HOSTNAME" -U "$USERNAME"
"$DATABASE" -f $FINAL_BACKUP_DIR"$DATABASE".custom.in_progress; then

echo "[!!ERROR!!] Failed to produce
custom backup database $DATABASE"

else

mv
$FINAL_BACKUP_DIR"$DATABASE".custom.in_progress
$FINAL_BACKUP_DIR"$DATABASE".custom

fi

fi

echo -e "\nAll database backups complete!"

}

# DAILY BACKUPS

# Delete daily backups 7 days old or more

find $BACKUP_DIR -maxdepth 1 -mtime +$DAYS_TO_KEEP -name "*-daily" -exec
rm -rf '{}' ';'


From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <adelaide-au-pug(at)postgresql(dot)org>,<pgsql-admin(at)postgresql(dot)org>, <pgsql-bugs(at)postgresql(dot)org>, <pgsql-sql(at)postgresql(dot)org>, <seapug(at)postgresql(dot)org>, "Mitesh Shah" <mitesh(dot)shah(at)stripes39(dot)com>
Subject: Re: [BUGS] pg_dump: aborting because of server version mismatch
Date: 2012-05-02 21:53:53
Message-ID: 4FA166A10200002500047721@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: adelaide-au-pug atlpug austinpug bostonpug bwpug pgsql-admin pgsql-bugs pgsql-sql seapug sfpug

Mitesh Shah <mitesh(dot)shah(at)stripes39(dot)com> wrote:

> *pg_dump: server version: 9.1.2; pg_dump version: 9.0.5*
> *pg_dump: aborting because of server version mismatch*

This is not a bug. Use a version of pg_dump which is at least as
new as the server. The older version of pg_dump is unlikely to be
able to recognize everything in the newer server,

-Kevin


From: Robert Bernier <rbernier(at)mediosystems(dot)com>
To: seapug(at)postgresql(dot)org
Cc: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>, adelaide-au-pug(at)postgresql(dot)org, pgsql-admin(at)postgresql(dot)org, pgsql-bugs(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org, "Mitesh Shah" <mitesh(dot)shah(at)stripes39(dot)com>
Subject: Re: [seapug] Re: [BUGS] pg_dump: aborting because of server version mismatchT
Date: 2012-05-02 22:27:49
Message-ID: 201205021527.50466.rbernier@mediosystems.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: adelaide-au-pug atlpug austinpug bostonpug bwpug pgsql-admin pgsql-bugs pgsql-sql seapug sfpug

There used to be a switch in pg_dump that would disable the version, you can
even see that's in the man page. However, it is not reccommended and the most
recent versions have fully deprecated the switch. Technically speaking that
means that you can even use an older version of pg_dump and it wouldn't
generate any errors although I wouldn't want to test it out on important stuff.

Robert Bernier

On Wednesday, May 02, 2012 02:53:53 pm Kevin Grittner wrote:
> Mitesh Shah <mitesh(dot)shah(at)stripes39(dot)com> wrote:
> > *pg_dump: server version: 9.1.2; pg_dump version: 9.0.5*
> > *pg_dump: aborting because of server version mismatch*
>
> This is not a bug. Use a version of pg_dump which is at least as
> new as the server. The older version of pg_dump is unlikely to be
> able to recognize everything in the newer server,
>
> -Kevin


From: Christophe Pettus <xof(at)thebuild(dot)com>
To: Mitesh Shah <mitesh(dot)shah(at)stripes39(dot)com>
Cc: sfpug(at)postgresql(dot)org, atlpug(at)postgresql(dot)org, austinpug(at)postgresql(dot)org, bostonpug(at)postgresql(dot)org, bwpug(at)postgresql(dot)org
Subject: Re: [sfpug] pg_dump: aborting because of server version mismatch
Date: 2012-05-03 03:27:28
Message-ID: 7DDB8E70-7E48-4EA5-8D54-A4E754971830@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: adelaide-au-pug atlpug austinpug bostonpug bwpug pgsql-admin pgsql-bugs pgsql-sql seapug sfpug

Hi, Mitesh,

The error means exactly what it says: You're trying to use the 9.0.5 version of pg_dump to dump a server running 9.1.2; you need a version of pg_dump that is no older than the server you are trying to do the dump from.

On May 2, 2012, at 12:58 PM, Mitesh Shah wrote:

> Hi,
> I am trying to create a daily backup cron script but it fails with an error as below:
>
> Any pointers to resolve this will be greatly appreciated.
>
> Thanks,
> Mitesh Shah
> mitesh(dot)shah(at)stripes39(dot)com
>
> (1) Error:
> bash-3.2$ sh pg_backup_rotated_orig.sh
> Making backup directory in /Users/miteshshah/Documents/2012-05-02-daily/
> -e
>
> Performing full backups
> -e --------------------------------------------
>
> Plain backup of mitesh
> pg_dump: server version: 9.1.2; pg_dump version: 9.0.5
> pg_dump: aborting because of server version mismatch
> -e
> All database backups complete!
>
>
>
> (2.1) /Users/miteshshah/Desktop/pg_backup.config file:
> #############################
> ## POSTGRESQL BACKUP CONFIG ##
> ##############################
> # hostname to adhere to pg_hba policies.
> HOSTNAME= <host>
>
> # username to connect to database as.
> USERNAME=<user>
>
> # Database name
> DATABASE=<database>
>
> # This dir will be created if it doesn't exist. This must be writable by the user the script is
> # running as.
> BACKUP_DIR=<backup_dir>
>
> # SCRIPTPATH
> SCRIPTPATH=<path>
>
> # Will produce a custom-format backup if set to "yes"
> ENABLE_CUSTOM_BACKUPS=yes
>
> # Will produce a gzipped plain-format backup if set to "yes"
> ENABLE_PLAIN_BACKUPS=yes
>
>
> #### SETTINGS FOR ROTATED BACKUPS ####
>
> # Which day to take the weekly backup from (1-7 = Monday-Sunday)
> DAY_OF_WEEK_TO_KEEP=5
>
> # Number of days to keep daily backups
> DAYS_TO_KEEP=7
>
> # How many weeks to keep weekly backups
> WEEKS_TO_KEEP=5
>
> ######################################
>
>
> (2.2) /Users/miteshshah/Desktop/pg_backup_rotated_orig.sh
> #!/bin/bash
>
> ###########################
> ####### LOAD CONFIG #######
> ###########################
>
> source /Users/miteshshah/Desktop/pg_backup.config
>
>
> ###########################
> #### START THE BACKUPS ####
> ###########################
>
> function perform_backups()
> {
> SUFFIX=$1
> FINAL_BACKUP_DIR=$BACKUP_DIR"`date +\%Y-\%m-\%d`$SUFFIX/"
>
> echo "Making backup directory in $FINAL_BACKUP_DIR"
>
> if ! mkdir -p $FINAL_BACKUP_DIR; then
> echo "Cannot create backup directory in $FINAL_BACKUP_DIR. Go and fix it!"
> exit 1;
> fi;
>
>
> ###########################
> ###### FULL BACKUPS #######
> ###########################
>
> echo -e "\n\nPerforming full backups"
> echo -e "--------------------------------------------\n"
>
>
>
> if [ $ENABLE_PLAIN_BACKUPS = "yes" ]
> then
> echo "Plain backup of $DATABASE"
>
> if ! pg_dump -Fp -h "$HOSTNAME" -U "$USERNAME" "$DATABASE" | gzip > $FINAL_BACKUP_DIR"$DATABASE".sql.gz.in_progress; then
> echo "[!!ERROR!!] Failed to produce plain backup database $DATABASE"
> else
> mv $FINAL_BACKUP_DIR"$DATABASE".sql.gz.in_progress $FINAL_BACKUP_DIR"$DATABASE".sql.gz
> fi
> fi
>
> if [ $ENABLE_CUSTOM_BACKUPS = "yes" ]
> then
> echo "Custom backup of $DATABASE"
>
> if ! pg_dump -Fc -h "$HOSTNAME" -U "$USERNAME" "$DATABASE" -f $FINAL_BACKUP_DIR"$DATABASE".custom.in_progress; then
> echo "[!!ERROR!!] Failed to produce custom backup database $DATABASE"
> else
> mv $FINAL_BACKUP_DIR"$DATABASE".custom.in_progress $FINAL_BACKUP_DIR"$DATABASE".custom
> fi
> fi
>
>
>
> echo -e "\nAll database backups complete!"
> }
>
> # DAILY BACKUPS
>
> # Delete daily backups 7 days old or more
> find $BACKUP_DIR -maxdepth 1 -mtime +$DAYS_TO_KEEP -name "*-daily" -exec rm -rf '{}' ';'
>
>

--
-- Christophe Pettus
xof(at)thebuild(dot)com


From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Mitesh Shah <mitesh(dot)shah(at)stripes39(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org, pgsql-bugs(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org, adelaide-au-pug(at)postgresql(dot)org, seapug(at)postgresql(dot)org
Subject: Re: [SQL] pg_dump: aborting because of server version mismatch
Date: 2012-05-11 19:39:18
Message-ID: 4FAD6AE6.6000904@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: adelaide-au-pug atlpug austinpug bostonpug bwpug pgsql-admin pgsql-bugs pgsql-sql seapug sfpug

On 05/02/2012 12:55 PM, Mitesh Shah wrote:
> Hi,
> I am trying to create a daily backup cron script but it fails with an
> error as below:
>
> Any pointers to resolve this will be greatly appreciated.
>
> Thanks,
> Mitesh Shah
> mitesh(dot)shah(at)stripes39(dot)com <mailto:mitesh(dot)shah(at)stripes39(dot)com>
>
> *(1) Error:*
> bash-3.2$ sh pg_backup_rotated_orig.sh
> Making backup directory in /Users/miteshshah/Documents/2012-05-02-daily/
> -e
>
> Performing full backups
> -e --------------------------------------------
>
> Plain backup of mitesh
> *pg_dump: server version: 9.1.2; pg_dump version: 9.0.5*

The problem is you are using an older version of pg_dump to dump a newer
database. That will not work.
Possible solution:
You are running via cron. Cron has its own environment. Unless you are
explicit in your pathing you can get surprising results, see above.
Find the path to the 9.1.2 version of pg_dump and use that absolute path
in your script.

> *pg_dump: aborting because of server version mismatch*
> -e
> All database backups complete!
>

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com