Sabtu, 15 Juni 2013

[Postgresql] Restore dan Dump Database

Malam ini mau tulis cara dump & restore pada database postgresql. Mungkin uda banyak ya, tutorial mengenai cara ini tapi karena hari ini gw pusing nyari-nyari di internet, mending gw tulis aja ya :nyengir.
Commandnya gampang, lihat aja di bawah ini.
Restore : psql -U {user-name} -d {desintation_db}-f {dumpfilename.sql}
Backup  : pg_dump -U {user-name} {source_db} -f {dumpfilename.sql}

Command di atas dapat digunakan dan tidak akan error jika config pada pg_hba.conf, seperti dibawah ini
# Database administrative login by Unix domain socket
local   all             postgres                                peer    # I comment this line
#local   all             postgres                                md5
local   all             postgres                                trust
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
#local   all             all                                     peer

local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
 
Sekian tulisan dari gw, kalau ga ngerti bisa liat di link ini