Skip to content

python script to create, download and upload to s3 your Jira or Confluence cloud instance backup

License

Notifications You must be signed in to change notification settings

cgoedel/jira-backup-py

 
 

Repository files navigation

datree-badge

Introduction

Jira and Confluence are not (officially) supporting the option of creating automatic backups for their cloud instance. This project was created to provide a fully automated infrastructure for backing up Atlassian Cloud Jira or Confluence instances on a periodic basis.

There are shell and bash scripts out there, which were created in order to download the backup file locally without the use of the "backup manager" UI, but most of them are not maintained and throwing errors. So, this project is aiming for full backup automation, and therefore this is the features road map:

✅ Create a script in python
✅ Support creating config.json from user input ('wizard')
✅ Download backup file locally
✅ Add an option to stream backup file to S3
✅ Check how to manually create a cron task on OS X / Linux
✅ Check how to manually create a schedule task on windows
🔲 Support adding cron / scheduled task from script    

Installation

Prerequisite:

➕ python 2.7.x or python 3.x.x
virtualenv installed globally (pip install virtualenv)

Instructions:

  1. Create and start virtual environment (in this example, the virtualenv will be called "venv")
  2. Install requirements
$(venv) pip install -r requirements.txt
  1. Generate an API token at https://id.atlassian.com/manage/api-tokens
    Screenshot
  2. Fill the details at the config.yaml file or run the backup.py script with '-w' flag
  3. Run backup.py script with the flag '-j' to backup Jira or '-c' to backup Confluence
$(venv) python backup.py 

Screenshot

What's next?

It depends on your needs. I, for example, use this script together with serverless to create a periodic AWS lambda which triggered every 4 days, creating a backup and upload it directly to S3.

There is a more "stupid" option to get the same result - by creating a cron / scheduled task on your local machine:

  • OS X / Linux: set a cron task with crontab
echo "* * * * * cd %script dir% && %activate virtualenv% && python backup.py > %log name% 2>&1" | crontab -

Example for adding a cron task which will run every 4 days, at 10:00

echo "0 10 */4 * * cd ~/Dev/jira-backup-py && source venv/bin/activate && python backup.py > backup_script.log 2>&1" | crontab -
  • Windows: set a scheduled task with task scheduler
schtasks /create /tn "%task name%" /sc DAILY /mo %number of days% /tr "%full path to win_task_wrapper.bat%" /st %start time%

Example for adding a scheduled task which will run every 4 days, at 10:00

schtasks /create /tn "jira-backup" /sc DAILY /mo 4 /tr "C:\jira-backup-py\win_task_wrapper.bat" /st 10:00

Changelog:

  • 04 SEP 2020 - Support Confluence backup
  • 16 JAN 2019 - Updated script to work w/ API token, instead personal Jira user name and password

Resources:

JIRA support - How to Automate Backups for JIRA Cloud applications
Atlassian Labs' automatic-cloud-backup script
A more maintainable version of Atlassian Labs' script

About

python script to create, download and upload to s3 your Jira or Confluence cloud instance backup

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 94.2%
  • Batchfile 5.8%