This is about right.
Please do not use port 5432 for PostgreSQL. Pick a non-default port well outside that range, like 5599 or something. Change the port by modifying postgresql.conf and setting the port
directive. You might find it useful to simply append include_dir = conf.d
or similar in your main postgresql.conf
then create a datadirconf.dmyapp.conf
with your configuration overrides.
To set the password for initdb
without a prompt, pass the --pwfile=/path/to/file
option. The first line will be read as the password. See initdb.
Your uninstall plan is reasonable and correct.
Think about upgrades though - don't paint yourself into a corner. You'll want to be able to install 9.5 in parallel to 9.4 and pg_upgrade
, unless you want to just use dump and restore.
I suggest installing the PostgreSQL binaries into %PROGRAMFILES%MyAppPostgreSQL9.4
. You should probably put the database into %PROGRAMDATA%MyAppPostgreSQL9.4
instead of your app's %PROGRAMFILES%
directory. (The PostgreSQL installer should do the same; its current behaviour is a historical artifact that should be fixed).
Please document that your application bundles PostgreSQL so that nobody "cleans" it up, and so we don't have yet another app spewing confused users onto pgsql-general. It gets tiring explaining to angry users that "we" didn't install PostgreSQL on their system, we can't remove it, it's probably there because it was installed by something they use, and if they delete it then that'll stop working. Similarly, it gets tiring explaining to users who just killed the PostgreSQL processes and deleted their PostgreSQL data dir that we can't get their Poker Tracker (or whatever) database back because they just deleted it...
Make sure your app exposes functionality to do PostgreSQL dumps and restores for users.
The user manual must clearly explain that they need to take extra backup steps to protect data in your app. You can't just use Windows Backup to get a reliable PostgreSQL backup because it's multiple files that must be copied together; it'll copy each file OK, but the combined result will be unusable unless PostgreSQL was stopped before the backup. To do a live backup you need to take special steps - pg_start_backup()
, copy, pg_stop_backup()
and archive the extra WAL segments, or use pg_basebackup
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…