Re: Running vacuum on cron
От | Steve Wolfe |
---|---|
Тема | Re: Running vacuum on cron |
Дата | |
Msg-id | 001401c160a4$04e98380$50824e40@iboats.com обсуждение исходный текст |
Ответ на | Running vacuum on cron (Pedro Alves <pmalves@think.co.pt>) |
Список | 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 по дате отправления: