1

I have a local copy of Bitbucket Server on my machine and i'm running tests before putting it on a server.

I'm trying to use the Bitbucket DIY Backup but every time I run the backup it completely deletes the directory the database should be backed up into and then tells me is cannot find the directory.

It backs up to the home and archive directories as it should with no issues but won't work for the database.

Here is the line used for creating the dump that seems to be causing the directory to be deleted:

mysqldump -username=root -password= --databases=bitbucket_server > ../bitbucket-backups-diy/bitbucket-database/bitbucket_server.sql

I have tested the connection settings on the line above with the following line and am getting a list of the tables in the database as I would expect:

mysql -D bitbucket_server -u root -p -e "show tables"

Any help would be greatly appreciated, thanks in advance.

Sam

Sam Roberts
  • 245
  • 2
  • 13
  • try $ls -l ../bitbucket-backups-diy/bitbucket-database/; if you got a error this directory not exsists. create it with $mkdir -p ../bitbucket-backups-diy/bitbucket-database/ and the do mysqldump again – Bernd Buffen Apr 25 '16 at 15:23
  • @BerndBuffen thanks but neither of those worked, both times the directory was deleted, the only time I have managed to not get the directory deleted was when I removed all write permissions for all users on the folder. But then it obviously failed because it couldn't write the backup to it. – Sam Roberts Apr 25 '16 at 15:37
  • try this: cd (go to home dir) then mysqldump -username=root -password= --databases=bitbucket_server >./dump.sql – Bernd Buffen Apr 25 '16 at 16:46
  • @BerndBuffen with a bit of tinkering I got 'mysqldump -uroot bitbucket_server >./dump.sql' to take a dump of the DB in to the home directory – Sam Roberts Apr 26 '16 at 09:06

1 Answers1

1

I have stopped the bash file from deleting the directory and now it stores the dump in there.

Thanks to @BerndBuffen I altered the way the dump was accessing my database. Instead of using:

mysqldump -username=root -password= --databases=bitbucket_server > ../bitbucket-backups-diy/bitbucket-database/bitbucket_server.sql

I now use:

mysqldump -uroot bitbucket_server > ../bitbucket-backups-diy/bitbucket-database/bitbucket_server.sql

You also need to add the following code to the line above mysqldump to create the folder:

mkdir -p ../bitbucket-backups-diy/bitbucket-database

Because my root user doesn't have a password on my local database I don't need to list a password, this looks to be the reason it was failing. For when I put the backup on to a live server I will just need to add -p back in to the script and it should work.

Hopefully this can help anyone else having this problem.

Sam

Sam Roberts
  • 245
  • 2
  • 13