Re: Running vacuum on cron - Mailing list pgsql-general

From Steve Wolfe
Subject Re: Running vacuum on cron
Date
Msg-id 001401c160a4$04e98380$50824e40@iboats.com
Whole thread Raw
In response to Running vacuum on cron  (Pedro Alves <pmalves@think.co.pt>)
List pgsql-general
> Hi. Is there any way to put a vacuum and a vacuum analyze (the
> second does everything the first does? Or do I need to use both?) in a
cron
> so that it is executed nightly?

# crontab -e -u postgres
0 0 * * * vacuumdb --all --analyze

  Depending on your path and binary locations, you may have to fully
qualify the "vacuumdb" command, such as
"/usr/local/pgsql/bin/vacuumdb --all --analyze".  You can also take the
opportunity to do backup stuff if you want, here's a simple example:

----------
#!/bin/sh

/usr/local/pgsql/bin/vacuumdb --all --analyze

DATESTAMP=`date +%B_%d_%Y__%H:%M:%S`
BACKUPDIR=/usr/local/pgsql/backup
FILENAME=pg_daily_backup__${DATESTAMP}.bz

/usr/local/pgsql/bin/pg_dumpall | /usr/bin/bzip2 > $BACKUPDIR/$FILENAME
---------------

  The location where you put the backups should be included in your normal
file backup routine.  Keeping a second copy on a trusted machine (say,
your file server) also makes it easier to get a file if things go very bad
in a hurry.

steve



pgsql-general by date:

Previous
From: Fran Fabrizio
Date:
Subject: Re: Running vacuum on cron
Next
From: Bruce Momjian
Date:
Subject: Re: initdb segfault - solaris 8