2002-02-19 09:23:22 +01:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
#
|
2002-08-26 10:12:40 +02:00
|
|
|
|
# $FreeBSD$
|
2002-02-19 09:23:22 +01:00
|
|
|
|
#
|
|
|
|
|
# Maintenance shell script to vacuum and backup database
|
|
|
|
|
# Put this in /usr/local/etc/periodic/daily, and it will be run
|
|
|
|
|
# every night
|
|
|
|
|
#
|
2003-01-04 02:10:15 +01:00
|
|
|
|
# Written by Palle Girgensohn <girgen@pingpong.net>
|
2002-02-19 09:23:22 +01:00
|
|
|
|
#
|
|
|
|
|
# In public domain, do what you like with it,
|
|
|
|
|
# and use it at your own risk... :)
|
|
|
|
|
#
|
2004-11-23 20:15:12 +01:00
|
|
|
|
|
|
|
|
|
# Define these variables in either /etc/periodic.conf or
|
|
|
|
|
# /etc/periodic.conf.local to override the default values.
|
2002-08-26 10:12:40 +02:00
|
|
|
|
#
|
Update all PostgreSQL ports to latest version.
Remove postgresql-contrib in favour for postgresqlNN-contrib.
This way we will get packages built, which is nice.
Security: CVE-2010-1169
Security: CVE-2010-1170
The PostgreSQL Project today released minor versions updating all active
branches of the PostgreSQL object-relational database system, including
versions 8.4.4, 8.3.11, 8.2.17, 8.1.21, 8.0.25, and 7.4.29. This release
fixes moderate-risk security issues with PL/perl and PL/tcl, as well as
a data corruption issue with standby databases. Users of any of these
three features should update their PostgreSQL installations immediately.
The PL/perl security fix closes a security hole in PL/perl
procedures which could allow privilege escalation on the host system,
caused by a flaw in Safe.pm; see CVE-2010-1169 and CVE-2010-1447 for
details. A second patch prevents PL/tcl's pltcl_modules table from
being subverted in order to run arbitrary Tcl scripts; see
CVE-2010-1170. These issues only affect users who have enabled either
of these two stored procedure languages.
Also corrected is use of the command ALTER TABLE SET TABLESPACE, which
previously could cause data corruption on Warm Standby database slaves.
This issue affects only version 8.4.
There are also 21 other bug fixes in this release, some of which apply
only to version 8.4, and a few of which are specifically for Windows.
While these are generally fixes for minor issues, among the changes are:
* Fix for a combinational crash condition
* Prevent normal users from resetting some GUCs in
their own role definitions
* Correctly apply constraint exclusion in UPDATE and DELETE queries
* Minor fixes for WAL archiving
* Update timezone data for 12 zones
See the release notes for a full list of changes with details.
Releasenotes at http://www.postgresql.org/docs/current/static/release.html
2010-05-20 17:43:39 +02:00
|
|
|
|
# daily_pgsql_backup_enable="YES" # do backup of all databases
|
|
|
|
|
# daily_pgsql_backup_enable="foo bar db1 db2" # only do backup of a limited selection of databases
|
2004-11-23 20:15:12 +01:00
|
|
|
|
# daily_pgsql_vacuum_enable="YES" # do vacuum
|
|
|
|
|
|
|
|
|
|
daily_pgsql_vacuum_args="-z"
|
|
|
|
|
daily_pgsql_pgdump_args="-b -F c"
|
|
|
|
|
# backupdir is relative to ~pgsql home directory unless it begins with a slash:
|
|
|
|
|
daily_pgsql_backupdir="~pgsql/backups"
|
|
|
|
|
daily_pgsql_savedays="7"
|
2002-02-19 09:23:22 +01:00
|
|
|
|
|
2004-11-23 20:15:12 +01:00
|
|
|
|
# If there is a global system configuration file, suck it in.
|
|
|
|
|
#
|
|
|
|
|
if [ -r /etc/defaults/periodic.conf ]
|
|
|
|
|
then
|
|
|
|
|
. /etc/defaults/periodic.conf
|
|
|
|
|
source_periodic_confs
|
2002-04-11 06:58:11 +02:00
|
|
|
|
fi
|
|
|
|
|
|
2004-11-23 20:15:12 +01:00
|
|
|
|
# allow '~<7E> in dir name
|
|
|
|
|
eval backupdir=${daily_pgsql_backupdir}
|
2002-08-26 10:12:40 +02:00
|
|
|
|
|
2004-11-23 20:15:12 +01:00
|
|
|
|
rc=0
|
2002-02-19 09:23:22 +01:00
|
|
|
|
|
Update all PostgreSQL ports to latest version.
Remove postgresql-contrib in favour for postgresqlNN-contrib.
This way we will get packages built, which is nice.
Security: CVE-2010-1169
Security: CVE-2010-1170
The PostgreSQL Project today released minor versions updating all active
branches of the PostgreSQL object-relational database system, including
versions 8.4.4, 8.3.11, 8.2.17, 8.1.21, 8.0.25, and 7.4.29. This release
fixes moderate-risk security issues with PL/perl and PL/tcl, as well as
a data corruption issue with standby databases. Users of any of these
three features should update their PostgreSQL installations immediately.
The PL/perl security fix closes a security hole in PL/perl
procedures which could allow privilege escalation on the host system,
caused by a flaw in Safe.pm; see CVE-2010-1169 and CVE-2010-1447 for
details. A second patch prevents PL/tcl's pltcl_modules table from
being subverted in order to run arbitrary Tcl scripts; see
CVE-2010-1170. These issues only affect users who have enabled either
of these two stored procedure languages.
Also corrected is use of the command ALTER TABLE SET TABLESPACE, which
previously could cause data corruption on Warm Standby database slaves.
This issue affects only version 8.4.
There are also 21 other bug fixes in this release, some of which apply
only to version 8.4, and a few of which are specifically for Windows.
While these are generally fixes for minor issues, among the changes are:
* Fix for a combinational crash condition
* Prevent normal users from resetting some GUCs in
their own role definitions
* Correctly apply constraint exclusion in UPDATE and DELETE queries
* Minor fixes for WAL archiving
* Update timezone data for 12 zones
See the release notes for a full list of changes with details.
Releasenotes at http://www.postgresql.org/docs/current/static/release.html
2010-05-20 17:43:39 +02:00
|
|
|
|
pgsql_backup() {
|
2004-11-23 20:15:12 +01:00
|
|
|
|
# daily_pgsql_backupdir must be writeable by user pgsql
|
|
|
|
|
# ~pgsql is just that under normal circumstances,
|
|
|
|
|
# but this might not be where you want the backups...
|
|
|
|
|
if [ ! -d ${backupdir} ] ; then
|
|
|
|
|
echo Creating ${backupdir}
|
Update all PostgreSQL ports to latest version.
Remove postgresql-contrib in favour for postgresqlNN-contrib.
This way we will get packages built, which is nice.
Security: CVE-2010-1169
Security: CVE-2010-1170
The PostgreSQL Project today released minor versions updating all active
branches of the PostgreSQL object-relational database system, including
versions 8.4.4, 8.3.11, 8.2.17, 8.1.21, 8.0.25, and 7.4.29. This release
fixes moderate-risk security issues with PL/perl and PL/tcl, as well as
a data corruption issue with standby databases. Users of any of these
three features should update their PostgreSQL installations immediately.
The PL/perl security fix closes a security hole in PL/perl
procedures which could allow privilege escalation on the host system,
caused by a flaw in Safe.pm; see CVE-2010-1169 and CVE-2010-1447 for
details. A second patch prevents PL/tcl's pltcl_modules table from
being subverted in order to run arbitrary Tcl scripts; see
CVE-2010-1170. These issues only affect users who have enabled either
of these two stored procedure languages.
Also corrected is use of the command ALTER TABLE SET TABLESPACE, which
previously could cause data corruption on Warm Standby database slaves.
This issue affects only version 8.4.
There are also 21 other bug fixes in this release, some of which apply
only to version 8.4, and a few of which are specifically for Windows.
While these are generally fixes for minor issues, among the changes are:
* Fix for a combinational crash condition
* Prevent normal users from resetting some GUCs in
their own role definitions
* Correctly apply constraint exclusion in UPDATE and DELETE queries
* Minor fixes for WAL archiving
* Update timezone data for 12 zones
See the release notes for a full list of changes with details.
Releasenotes at http://www.postgresql.org/docs/current/static/release.html
2010-05-20 17:43:39 +02:00
|
|
|
|
mkdir -m 700 ${backupdir}; chown pgsql ${backupdir}
|
2004-11-23 20:15:12 +01:00
|
|
|
|
fi
|
2002-02-19 09:23:22 +01:00
|
|
|
|
|
2004-11-23 20:15:12 +01:00
|
|
|
|
echo
|
Update all PostgreSQL ports to latest version.
Remove postgresql-contrib in favour for postgresqlNN-contrib.
This way we will get packages built, which is nice.
Security: CVE-2010-1169
Security: CVE-2010-1170
The PostgreSQL Project today released minor versions updating all active
branches of the PostgreSQL object-relational database system, including
versions 8.4.4, 8.3.11, 8.2.17, 8.1.21, 8.0.25, and 7.4.29. This release
fixes moderate-risk security issues with PL/perl and PL/tcl, as well as
a data corruption issue with standby databases. Users of any of these
three features should update their PostgreSQL installations immediately.
The PL/perl security fix closes a security hole in PL/perl
procedures which could allow privilege escalation on the host system,
caused by a flaw in Safe.pm; see CVE-2010-1169 and CVE-2010-1447 for
details. A second patch prevents PL/tcl's pltcl_modules table from
being subverted in order to run arbitrary Tcl scripts; see
CVE-2010-1170. These issues only affect users who have enabled either
of these two stored procedure languages.
Also corrected is use of the command ALTER TABLE SET TABLESPACE, which
previously could cause data corruption on Warm Standby database slaves.
This issue affects only version 8.4.
There are also 21 other bug fixes in this release, some of which apply
only to version 8.4, and a few of which are specifically for Windows.
While these are generally fixes for minor issues, among the changes are:
* Fix for a combinational crash condition
* Prevent normal users from resetting some GUCs in
their own role definitions
* Correctly apply constraint exclusion in UPDATE and DELETE queries
* Minor fixes for WAL archiving
* Update timezone data for 12 zones
See the release notes for a full list of changes with details.
Releasenotes at http://www.postgresql.org/docs/current/static/release.html
2010-05-20 17:43:39 +02:00
|
|
|
|
echo "PostgreSQL backups"
|
2002-02-19 09:23:22 +01:00
|
|
|
|
|
2004-11-23 20:15:12 +01:00
|
|
|
|
# Protect the data
|
|
|
|
|
umask 077
|
|
|
|
|
rc=$?
|
|
|
|
|
now=`date "+%Y-%m-%dT%H:%M:%S"`
|
|
|
|
|
file=${daily_pgsql_backupdir}/pgglobals_${now}
|
2008-06-13 01:46:07 +02:00
|
|
|
|
su -l pgsql -c "umask 077; pg_dumpall -g | gzip -9 > ${file}.gz"
|
Update all PostgreSQL ports to latest version.
Remove postgresql-contrib in favour for postgresqlNN-contrib.
This way we will get packages built, which is nice.
Security: CVE-2010-1169
Security: CVE-2010-1170
The PostgreSQL Project today released minor versions updating all active
branches of the PostgreSQL object-relational database system, including
versions 8.4.4, 8.3.11, 8.2.17, 8.1.21, 8.0.25, and 7.4.29. This release
fixes moderate-risk security issues with PL/perl and PL/tcl, as well as
a data corruption issue with standby databases. Users of any of these
three features should update their PostgreSQL installations immediately.
The PL/perl security fix closes a security hole in PL/perl
procedures which could allow privilege escalation on the host system,
caused by a flaw in Safe.pm; see CVE-2010-1169 and CVE-2010-1447 for
details. A second patch prevents PL/tcl's pltcl_modules table from
being subverted in order to run arbitrary Tcl scripts; see
CVE-2010-1170. These issues only affect users who have enabled either
of these two stored procedure languages.
Also corrected is use of the command ALTER TABLE SET TABLESPACE, which
previously could cause data corruption on Warm Standby database slaves.
This issue affects only version 8.4.
There are also 21 other bug fixes in this release, some of which apply
only to version 8.4, and a few of which are specifically for Windows.
While these are generally fixes for minor issues, among the changes are:
* Fix for a combinational crash condition
* Prevent normal users from resetting some GUCs in
their own role definitions
* Correctly apply constraint exclusion in UPDATE and DELETE queries
* Minor fixes for WAL archiving
* Update timezone data for 12 zones
See the release notes for a full list of changes with details.
Releasenotes at http://www.postgresql.org/docs/current/static/release.html
2010-05-20 17:43:39 +02:00
|
|
|
|
|
|
|
|
|
db=$1
|
|
|
|
|
while shift; do
|
2004-11-23 20:15:12 +01:00
|
|
|
|
echo -n " $db"
|
|
|
|
|
file=${backupdir}/pgdump_${db}_${now}
|
2008-06-13 01:46:07 +02:00
|
|
|
|
su -l pgsql -c "umask 077; pg_dump ${daily_pgsql_pgdump_args} -f ${file} ${db}"
|
2004-11-23 20:15:12 +01:00
|
|
|
|
[ $? -gt 0 ] && rc=3
|
Update all PostgreSQL ports to latest version.
Remove postgresql-contrib in favour for postgresqlNN-contrib.
This way we will get packages built, which is nice.
Security: CVE-2010-1169
Security: CVE-2010-1170
The PostgreSQL Project today released minor versions updating all active
branches of the PostgreSQL object-relational database system, including
versions 8.4.4, 8.3.11, 8.2.17, 8.1.21, 8.0.25, and 7.4.29. This release
fixes moderate-risk security issues with PL/perl and PL/tcl, as well as
a data corruption issue with standby databases. Users of any of these
three features should update their PostgreSQL installations immediately.
The PL/perl security fix closes a security hole in PL/perl
procedures which could allow privilege escalation on the host system,
caused by a flaw in Safe.pm; see CVE-2010-1169 and CVE-2010-1447 for
details. A second patch prevents PL/tcl's pltcl_modules table from
being subverted in order to run arbitrary Tcl scripts; see
CVE-2010-1170. These issues only affect users who have enabled either
of these two stored procedure languages.
Also corrected is use of the command ALTER TABLE SET TABLESPACE, which
previously could cause data corruption on Warm Standby database slaves.
This issue affects only version 8.4.
There are also 21 other bug fixes in this release, some of which apply
only to version 8.4, and a few of which are specifically for Windows.
While these are generally fixes for minor issues, among the changes are:
* Fix for a combinational crash condition
* Prevent normal users from resetting some GUCs in
their own role definitions
* Correctly apply constraint exclusion in UPDATE and DELETE queries
* Minor fixes for WAL archiving
* Update timezone data for 12 zones
See the release notes for a full list of changes with details.
Releasenotes at http://www.postgresql.org/docs/current/static/release.html
2010-05-20 17:43:39 +02:00
|
|
|
|
db=$1
|
2004-11-23 20:15:12 +01:00
|
|
|
|
done
|
2002-02-19 09:23:22 +01:00
|
|
|
|
|
2004-11-23 20:15:12 +01:00
|
|
|
|
if [ $rc -gt 0 ]; then
|
|
|
|
|
echo
|
|
|
|
|
echo "Errors were reported during backup."
|
|
|
|
|
fi
|
2002-02-19 09:23:22 +01:00
|
|
|
|
|
2004-11-23 20:15:12 +01:00
|
|
|
|
# cleaning up old data
|
|
|
|
|
find ${backupdir} \( -name 'pgdump_*' -o -name 'pgglobals_*' \) \
|
|
|
|
|
-a -mtime +${daily_pgsql_savedays} -delete
|
Update all PostgreSQL ports to latest version.
Remove postgresql-contrib in favour for postgresqlNN-contrib.
This way we will get packages built, which is nice.
Security: CVE-2010-1169
Security: CVE-2010-1170
The PostgreSQL Project today released minor versions updating all active
branches of the PostgreSQL object-relational database system, including
versions 8.4.4, 8.3.11, 8.2.17, 8.1.21, 8.0.25, and 7.4.29. This release
fixes moderate-risk security issues with PL/perl and PL/tcl, as well as
a data corruption issue with standby databases. Users of any of these
three features should update their PostgreSQL installations immediately.
The PL/perl security fix closes a security hole in PL/perl
procedures which could allow privilege escalation on the host system,
caused by a flaw in Safe.pm; see CVE-2010-1169 and CVE-2010-1447 for
details. A second patch prevents PL/tcl's pltcl_modules table from
being subverted in order to run arbitrary Tcl scripts; see
CVE-2010-1170. These issues only affect users who have enabled either
of these two stored procedure languages.
Also corrected is use of the command ALTER TABLE SET TABLESPACE, which
previously could cause data corruption on Warm Standby database slaves.
This issue affects only version 8.4.
There are also 21 other bug fixes in this release, some of which apply
only to version 8.4, and a few of which are specifically for Windows.
While these are generally fixes for minor issues, among the changes are:
* Fix for a combinational crash condition
* Prevent normal users from resetting some GUCs in
their own role definitions
* Correctly apply constraint exclusion in UPDATE and DELETE queries
* Minor fixes for WAL archiving
* Update timezone data for 12 zones
See the release notes for a full list of changes with details.
Releasenotes at http://www.postgresql.org/docs/current/static/release.html
2010-05-20 17:43:39 +02:00
|
|
|
|
echo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "$daily_pgsql_backup_enable" in
|
|
|
|
|
[Yy][Ee][Ss])
|
|
|
|
|
dbnames=`su -l pgsql -c "umask 077; psql -q -t -A -d template1 -c SELECT\ datname\ FROM\ pg_database\ WHERE\ datname!=\'template0\'"`
|
|
|
|
|
pgsql_backup $dbnames
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
[Nn][Oo])
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
"")
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
*)
|
|
|
|
|
pgsql_backup $daily_pgsql_backup_enable
|
2004-11-23 20:15:12 +01:00
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
case "$daily_pgsql_vacuum_enable" in
|
|
|
|
|
[Yy][Ee][Ss])
|
2002-02-19 09:23:22 +01:00
|
|
|
|
|
2004-11-23 20:15:12 +01:00
|
|
|
|
echo
|
Update all PostgreSQL ports to latest version.
Remove postgresql-contrib in favour for postgresqlNN-contrib.
This way we will get packages built, which is nice.
Security: CVE-2010-1169
Security: CVE-2010-1170
The PostgreSQL Project today released minor versions updating all active
branches of the PostgreSQL object-relational database system, including
versions 8.4.4, 8.3.11, 8.2.17, 8.1.21, 8.0.25, and 7.4.29. This release
fixes moderate-risk security issues with PL/perl and PL/tcl, as well as
a data corruption issue with standby databases. Users of any of these
three features should update their PostgreSQL installations immediately.
The PL/perl security fix closes a security hole in PL/perl
procedures which could allow privilege escalation on the host system,
caused by a flaw in Safe.pm; see CVE-2010-1169 and CVE-2010-1447 for
details. A second patch prevents PL/tcl's pltcl_modules table from
being subverted in order to run arbitrary Tcl scripts; see
CVE-2010-1170. These issues only affect users who have enabled either
of these two stored procedure languages.
Also corrected is use of the command ALTER TABLE SET TABLESPACE, which
previously could cause data corruption on Warm Standby database slaves.
This issue affects only version 8.4.
There are also 21 other bug fixes in this release, some of which apply
only to version 8.4, and a few of which are specifically for Windows.
While these are generally fixes for minor issues, among the changes are:
* Fix for a combinational crash condition
* Prevent normal users from resetting some GUCs in
their own role definitions
* Correctly apply constraint exclusion in UPDATE and DELETE queries
* Minor fixes for WAL archiving
* Update timezone data for 12 zones
See the release notes for a full list of changes with details.
Releasenotes at http://www.postgresql.org/docs/current/static/release.html
2010-05-20 17:43:39 +02:00
|
|
|
|
echo "PostgreSQL vacuum"
|
2004-11-23 20:15:12 +01:00
|
|
|
|
su -l pgsql -c "vacuumdb -a -q ${daily_pgsql_vacuum_args}"
|
|
|
|
|
if [ $? -gt 0 ]
|
|
|
|
|
then
|
|
|
|
|
echo
|
|
|
|
|
echo "Errors were reported during vacuum."
|
|
|
|
|
rc=3
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
esac
|
2002-04-11 06:58:11 +02:00
|
|
|
|
|
2002-02-19 09:23:22 +01:00
|
|
|
|
exit $rc
|