gagal pg_dump via cron di ubuntu

untuk melakukan backup database postgresql secara otomatis, dapat dilakukan lewat cron. perintah berikut ini berjalan dengan baik di redhat namun gagal di ubuntu. perintah memang dijalankan oleh cron namun menghasilkan file dengan ukuran nol (zero file size).

05 20 * * * root /usr/lib/postgresql/8.4/bin/pg_dump -h localhost -p 5432 \
-U postgres -F c -b -v -f "/home/pgdata/namadatabase.sql" namadatabase

konfigurasi di pg_hba.conf sebagai berikut :

# Database administrative login by UNIX sockets
local   all         postgres                          ident
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
# "local" is for Unix domain socket connections only
local   all         all                               ident
# IPv4 local connections:
host    all         all         127.0.0.1/32          trust

solusinya sangat sederhana, yaitu dengan menambahkan perintah 
untuk mengalihkan stderr ke suatu file di bagian akhir, sehingga 
menjadi seperti berikut :

05 20 * * * root /usr/lib/postgresql/8.4/bin/pg_dump -h localhost -p 5432 \
-U postgres -F c -b -v -f "/home/pgdata/namadatabase.sql" namadatabase \
2> /home/pgdata/stderr.txt

lalu restart cron

$ service cron restart
Tagged with: , , , ,
Posted in linux
2 comments on “gagal pg_dump via cron di ubuntu
  1. KACONG says:

    TRIMA KASIH, SANGAT BERGUNA, KALO BOLEH TAU DARI MANA SUMBERNYA YA ???

  2. gregor says:

    @kacong:kayaknya dulu di archive suatu milis, saya lupa namanya.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

TWEETS

Don't be too proud just because you use android or apple or blackberry if you fail to make your life more productive with them.

About 6 days ago