Looking at the DIY backup for PostgreSQL some questions come up.
This procedure is based on principle that restore to existing home and existing database is wrong
When restoring Bitbucket Server, you must run the <span>bitbucket.diy-restore.sh</span> script on the machine that Bitbucket Server should be restored to. In order to ensure accidental restores do not delete existing data, you should never restore into an existing home directory.
That we should setup backup and restore in such a way that prevent "accidental restores" is not a point of discussion of course but the idea that the restore script should not allow this altogether I'm not sure.
If we are worried about users running restore script without thinking the restore script could show a warning and ask for confirmation to continue. And ideally the script would also support performing restore without user interaction by providing a confirmation in the form of an extra argument / token on the command line.
As things stand the restore is unclear . I can provide restore script an empty database and restore will just fail saying the database already exists.
ERROR: Cannot restore over existing database 'bitbucket', please ensure it does not exist before restoring
Now I have to elevate privileges of my bitbucket database account in a unknown and undocumented way to allow it to create the database itself? I'm not sure.
In any case, current documentation describes that the database should be created the same way as for fresh install. Fresh install requires database schema to be created in advance. Restore demands the database does not exist at all. This is also not consistent.
How does this restore work in practice? Should I just use user postgres all the time? That account has the necessary privileges of course to create databases and so forth?
Is this the recommended setup?
https://confluence.atlassian.com/bitbucketserver/using-bitbucket-server-diy-backup-776640056.html