How to pass in password to pg_dump?

后端 未结 16 854
深忆病人
深忆病人 2020-11-28 00:58

I\'m trying to create a cronjob to back up my database every night before something catastrophic happens. It looks like this command should meet my needs:

0          


        
16条回答
  •  心在旅途
    2020-11-28 01:13

    This one liner helps me while creating dump of a single database.

    PGPASSWORD="yourpassword" pg_dump -U postgres -h localhost mydb > mydb.pgsql
    

提交回复
热议问题