From: | "Brent R(dot) Matzelle" <bmatzelle(at)yahoo(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: vacuum and backup |
Date: | 2001-02-27 18:19:31 |
Message-ID: | 20010227181931.9803.qmail@web312.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> 3) Has anyone written some shell scripts to do vacuum and
> backup?
> I will have to write some but am not conversant with shell
> scripts and
> would greatly appreciate any help.
You would probably be better off writing your scripts in a
system language such as Python or Perl. Here is an excerpt from
a basic Python backup program I wrote (uses pg_dump &
postgresql-python) that does just that.
#!/usr/bin/python
import os, time
from pg import DB
# Backup database with the current date attached
def pg_backup():
now = time.localtime(time.time())
today = time.strftime("%m-%d-%Y", now)
os.system("pg_dump test > test-%s.sql" % today)
print "Backup completed"
# Run vacuum on database
def pg_clean():
cxn = DB('test')
cxn.query("VACUUME VERBOSE ANALYZE")
print "Database optimized & space recovered"
### This is the main program ###
if __name__ == "__main__":
pg_backup()
pg_clean()
Brent
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Doug McNaught | 2001-02-27 18:37:08 | Re: vacuum and backup |
Previous Message | Brent R. Matzelle | 2001-02-27 18:04:18 | Re: PHP4.0.4pl1 and PostgreSQL 7.1beta4 |