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

1 vote

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 Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

23,328 views 26 12
Join discussion

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