Arts Management Systems
Cheat Sheet
http://www.artsman.com
PostgreSQLTerminalCommandsWindows
Starting/StoppingtheServer
Refer to: http://www.postgresql.org/docs/9.0/interactive/app-pg-ctl.html
1.
2.
3.
4.
5.
Open Control Panel
Open Administrative Tools
Open Services
Find the PostgreSQL Server service
Start, Stop or Restart the service
ReloadingChangestotheConfigurationFile
Refer to: http://www.postgresql.org/docs/9.0/interactive/app-pg-ctl.html - simply sends the postgres process a SIGHUP signal, causing
it to reread its configuration files (postgresql.conf, pg_hba.conf, etc.). This allows changing of configuration-file options that do not
require a complete restart to take effect.
1.
2.
3.
Open Command Prompt
Go to C:\Program Files\PostgreSQL\9.0\bin (Do cd.. to get back to C: prompt then type cd "Program Files" - enter - cd
PostgreSQL - enter - cd 9.0 enter - cd bin - enter
pg_ctl reload
BackingUpADatabase
Uncompressed backups from this point forward will use the .sql extenstion, while compressed backups will use the .backup
extension.
WindowsUncompressed
1.
2.
3.
Open Command Prompt
Go to C:\Program Files\PostgreSQL\9.0\bin (Do cd.. to get back to C: prompt then type cd "Program Files" - enter - cd
PostgreSQL - enter - cd 9.0 enter - cd bin - enter
pg_dump -U postgres -o [DatabaseName] > [Path] e.g For Database 'Demo' -> pg_dump -U postgres -o Demo >
/Users/Shared/MyBackups/Demo.sql
WindowsCompressed
1.
2.
3.
Open Command Prompt
Go to C:\Program Files\PostgreSQL\9.0\bin (Do cd.. to get back to C: prompt then type cd "Program Files" - enter - cd
PostgreSQL - enter - cd 9.0 enter - cd bin - enter
pg_dump -U postgres -o -F c -Z 9 [DatabaseName] > [Path] e.g For Database 'Demo' -> pg_dump -U postgres -o -F c -Z 9
Demo > /Users/Shared/MyBackups/Demo.backup
WindowsCompressed(viapgAdminonadifferentmachinethentheserver)
1.
2.
3.
Open Command Prompt
Go to C:\Program Files\pgAdmin III\1.12 (Do cd.. to get back to C: prompt then type cd "Program Files" - enter - cd pgAdmin
III - enter - cd 1.12 enter
pg_dump --host [IP address of server] --port 5432 --username "postgres" --format=c --compress=9 --file
"C:\BoxOffice\[DatabaseBackupName].backup [DatabaseName] e.g For Database 'Demo' -> pg_dump --host 192.168.0.3 -port 5432 --username "postgres" --format=c --compress=9 --file "C:\BoxOffice\Demo.backup" Demo
2011, Arts Management Systems
Arts Management Systems
Cheat Sheet
http://www.artsman.com
RestoringaDatabase
WindowsUncompressed
1.
2.
3.
Open Command Prompt
Go to C:\Program Files\PostgreSQL\9.0\bin (Do cd.. to get back to C: prompt then type cd "Program Files" - enter - cd
PostgreSQL - enter - cd 9.0 enter - cd bin - enter
Type psql -U postgres [DatabaseName] < [Path] e.g for Database 'Demo' -> psql -U postgres Demo <
/Users/Shared/MyBackups/Demo.sql
WindowsCompressed
Open Command Prompt
1.
2.
Go to C:\Program Files\PostgreSQL\9.0\bin (Do cd.. to get back to C: prompt then type cd "Program Files" - enter - cd
PostgreSQL - enter - cd 9.0 enter - cd bin - enter
Type pg_restore -U postgres -d [DatabaseName] [Path] e.g for Database 'Demo' -> pg_restore -U postgres -d Demo
/Users/Shared/MyBackups/Demo.backup
2011, Arts Management Systems