Cron job for backup client gives exceptions

I'm trying to setup a crontab for running backup on an Ubuntu Server 16.04, and I'm getting exceptions randomly. The cron job is set up correctly, using webmin.

The exception I get is:

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'appHome' defined in class path resource [META-INF/spring/common-spring.xml]: Could not resolve placeholder 'bitbucket.home' in string value "${bitbucket.home}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'bitbucket.home' in string value "${bitbucket.home}"
2016-10-10 21:51:01,545 ERROR        BITBUCKET_HOME is not defined.
Creating a backup requires direct, filesystem access to BITBUCKET_HOME for the instance being backed up, in order to backup its repositories.
BITBUCKET_HOME may be set using an environment variable, a system property (bitbucket.home) or configured in backup-config.properties.
When running the job manually with:

The BICKBUCKET_HOME variable is

/var/atlassian/application-data/bitbucket

This is also set in backup-config.properties, in bitbucket.home=.

 

When I ran it manually as the user "root" the first five or so times with the following command

java jar /home/userwtih-root-premission/bitbucket-backup-client-3.3.0/bitbucket-backup-client.jar

it was all good, until i suddenly got the following exception:

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'restClient' defined in class path resource [META-INF/spring/backup-spring.xml]: Could not resolve placeholder 'bitbucket.password' in string value "${bitbucket.password}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'bitbucket.password' in string value "${bitbucket.password}"

All the environment variables are set. All the values are set in backup-config.properties, and of course they are set correctly, since I could run it manually the first few times.

I have no idea why I'm experiencing this strange behavior. Please help me find a solution. If I must provide more information, please tell me what information you require, and where I find it if it's a log file or something.

Best regards,

Morten

1 answer

1 accepted

Hi Morten,

The bitbucket.properties file is read from wherever directory you run the java command. On your cronjob, are you doing a cd to the directory where this file is before executing? Same question applies for the case when you're running as root.

Regards,

Thiago

That was it. I changed my cronjob to:

08 09 * * * cd /home/user-with-root-permission/bitbucket-backup-client-3.3.0 && java -jar bitbucket-backup-client.jar

Thank you smile

Not a problem! Glad it helped. smile

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

710 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot