How to install postgres with NSIS with all parameters?

心不动则不痛 提交于 2019-11-29 16:22:37

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 datadir\conf.d\myapp.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%\MyApp\PostgreSQL\9.4. You should probably put the database into %PROGRAMDATA%\MyApp\PostgreSQL\9.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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!