Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible bitbucket backup on docker execution environment?

ujkimbitbucket July 10, 2018

Hello!

I'm working on docker bitbucket recent version and docker postgres recent version.

I want to backup bitbucket repository automatically.

In this situation, I got the Atlassian manual page related to this issue. (Bitbucket-Backup)

Backup Script need to set on information related to environment.

But.. Because of working on postgresql's docker, POSTGRES_HOST information is useless.

Independently, postgresql's docker is possible pg_dump(table what I want to insert).

In this situation, I want to know how to set the auto backup configuration.

Can I have some information about this issue?

 

Have a nice day!

 

1 answer

1 accepted

1 vote
Answer accepted
Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 12, 2018

Hi @ujkimbitbucket,

When running Bitbucket Server in Docker, you can still use the DIY option but there will likely need some adjustments to be made.

High level, what is required is the following:

- Stop Bitbucket or put it in maintenance mode / lock it

- create a backup of the database

- create a backup of the home directory

 

The backup of the database can be performed using the proprietary tools (e.g. pg_dump). If the database is in Docker, you may want to refer to the database documentation for details.

 

For the backup of the filesystem instead, the Bitbucket data should be available on volume mounted on the host and the backup/copy can then be taken directly from the host.

 

Cheers,

Caterina - Atlassian

ujkimbitbucket July 12, 2018

Thank you for request!

Thanks for information.

I have a question about your contents.

I was set on environment bitbucket docker with adding the volume option.

but bitbucket volumn path is not exist related to bitbucket files, bitbucket is successfully working on now. I use the bitbucket docker(https://bitbucket.org/atlassian/docker-atlassian-bitbucket-server)

docker run command is below.

docker run --name bitbucket -itd --restart always \
--env 'JVM_MAXIMUM_MEMORY=1G' \
--publish 7990:7990 \
--publish 7999:7999 \
--volume /docker/bitbucket:/var/atlassian/bitbucket \ 
--link postgresql:bitbucket \atlassian/bitbucket-server:latest

Can I get some information about this situation?

Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 15, 2018

Hi @ujkimbitbucket,

If I'm reading correctly your reply, the following folder on the host does not contain any Bitbucket Server data:

/docker/bitbucket

That seems reasonable considering that the mapping is expected to be set in the following way:

-v /data/bitbucket:/var/atlassian/application-data/bitbucket

This is because the /var/atlassian/application-data/bitbucket is the default home directory for Bitbucket Server.

Is this the home directory also in this installation?

 

If that's the case, I would recommend doing this:

- copy the home directory outside of the Docker container (not in /docker/bitbucket)

- stop the container

- move the home directory to the expected directory on the host

- start a new container with the expected volume mapping

 

Once this is all in place, the backup can be done from the host.

 

What do you think?

ujkimbitbucket July 15, 2018

@Caterina Curti! Thank you for your reply!

I resolved this problem thanks to your advise.

The cause was invalid bitbucket base home directory with docker running option.

Now logging file successfully saving in log directory.

Thank you ^^

Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 15, 2018

Glad to hear that everything is working now!

Thanks for your feedback @ujkimbitbucket!

ujkimbitbucket July 16, 2018

@Caterina Curti! I'm sorry.

I forgot our automatic backup problem because of bitbucket logging fail issue was resolved. I'm sorry ㅜ.ㅜ

Now bitbucket-diy script automatic backup routine was already completed.

One problem is postgres db backup procedure.

Now backup of the filesystem is successfully saved as bitbucket diy script.

But backup of the database is not saved because of docker's postgresql.

 

I think about it, This problem is below (script)

function backup_db {
rm -r "${BITBUCKET_BACKUP_DB}"
run pg_dump -U "${POSTGRES_USERNAME}" -h "${POSTGRES_HOST}" --port=${POSTGRES_PORT} ${PG_PARALLEL} -Fd \
"${BITBUCKET_DB}" ${PG_SNAPSHOT_OPT} -f "${BITBUCKET_BACKUP_DB}"
}

//////
BITBUCKET_DB=bitbucket
POSTGRES_HOST=127.0.0.1
POSTGRES_USERNAME=postgres
export PGPASSWORD=
POSTGRES_PORT=5432

As this configuration, db backup is failed.

Therefore I try to correct below (along the docker backup method)

function backup_db {
rm -r "${BITBUCKET_BACKUP_DB}"
docker exec -t postgresql pg_dump "${BITBUCKET_DB}" -c -U "${POSTGRES_USERNAME}" -f "${BITBUCKET_BACKUP_DB}"
}

# postgresql is docker container name.

error is blow.

[common.sh:58 -> backup_wait][localhost.localdomain] ERROR: Unable to start Bitbucket backup, because it could not enter DRAINED state
Stack trace:

      [./common.sh:58 -> backup_wait]
        [./bitbucket.diy-backup.sh:0 -> main]

 

As automatic script adjustment, is it possible?

if you know how to postgresql dump method, Can I get some information?

I'm sorry to bring you back to the issue you thought you were over.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events