Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket diy backup restore script

Onno van der Straaten July 8, 2018

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 bitbucket.diy-restore.sh 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

1 answer

0 votes
Baskar Annamalai
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 10, 2018

Hi @Onno van der Straaten

The DIY backup script provides the flexibility on the backup and restores instance as the user(system administrator) be able to configure the script based on their requirement and needs. 

As for the restoring the backup for the existing home and database, as for comparing the data in the current instance is updated compared to the backup thus restoring the existing home and database will cause conflict while the latest changes to the instance still remain unchanged.

The user should not able to run the script and its expected that only the System Administrator has control over the backup and restoring the instance. The script is meant to own configuration if you are looking into the warning and confirmation on the script.

The restore script does expect a database with schema initiated and prevent restoring data to a database that have been populated with data to avoid overriding. The dedicated database for Bitbucket Server should have permission to create, edit and delete data in the database and this user credential should allow the restore instead of the postgres user.

The recommendation in Using Bitbucket Server DIY Backup is given as a guidline. Feel free to go around it before finalizing the comfortable and convenient backup strategy for you.

Regards,

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events