Posts

Showing posts with the label pg_dump

Automate PostgreSql Backup with Cron

  Create The  Postgres Password File The file  .pgpass  in a user’s home directory can contain passwords to be used if the connection requires a password (and no password has been specified otherwise). On Microsoft Windows the file is named  %APPDATA%\postgresql\pgpass.conf  (where  %APPDATA%  refers to the Application Data subdirectory in the user’s profile). Alternatively, the password file to use can be specified using the connection parameter passfile or the environment variable  PGPASSFILE . Let’s see if the  postgres user  already has a password: sudo -u postgres psql select * from pg_authid; If  rolpassword  is empty, set the password: ALTER USER postgres PASSWORD 'mypassword'; \q Create  .pgpass vim ~/.pgpass # Add the following line # hostname:port:database:username:password localhost:*:*:postgres:[password] Add Environment variable  PGPASSFILE export PGPASSFILE= '/root/.pgpass' vim /etc/environment ...