Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7aa2173
Bump urllib3 from 1.24.2 to 1.26.5
dependabot[bot] Jun 1, 2021
18ef79c
Merge pull request #11 from datreeio/dependabot/pip/urllib3-1.26.5
Jun 16, 2021
8855d1b
fix requirements
DanielWeeber Feb 7, 2022
bac33b9
Merge pull request #12 from DanielWeeber/master
Feb 8, 2022
2e22d13
add S3_DIR and S3_ENDPOINT_URL
Dec 2, 2022
9227339
replace format
Dec 5, 2022
e7cd54f
Merge pull request #14 from nuBacuk/master
Dec 5, 2022
7f2be47
Change the boto module to boto3 and adapt the code #17
mathieumaf Sep 19, 2024
614f24c
Fixed the requirements.txt file #17
mathieumaf Sep 19, 2024
6321dcf
Merge pull request #19 from MATMAF/master
eyarz Sep 22, 2024
6eadcfe
Adapt the wizard.py file to Python 3 #20
Sep 24, 2024
4f03878
Adapt the wizard.py file to Python 3 #20
eyarz Sep 25, 2024
a1e4a07
File __init__.py is empty and never used
Sep 25, 2024
979db83
Changed .gitignore to add __pycache__ directory
mathieumaf Sep 25, 2024
890e380
Changed file README.md to only support python3
mathieumaf Sep 25, 2024
337c77e
Changed README.md to adapt config.json to config.yaml
mathieumaf Sep 25, 2024
c1d76bc
Changed boto3 version in requirements.txt
mathieumaf Sep 25, 2024
ba67450
Merge pull request #22 from MATMAF/master
eyarz Sep 26, 2024
087e369
feat: add GCP and Azure storage support
Trozz Jun 24, 2025
0bb0ca8
docs: update README with GCP and Azure storage instructions
Trozz Jun 24, 2025
b1d2385
feat: add automated scheduling support for backup tasks
Trozz Jun 24, 2025
6a206bf
feat: make cloud storage configuration sections optional
Trozz Jun 24, 2025
351d0df
fix: allow separate cron schedules for Jira and Confluence backups
Trozz Jun 24, 2025
ab6657d
docs: modernize README with comprehensive documentation and features
Trozz Jun 24, 2025
4e59c20
docs: fix README to reflect actual implemented features
Trozz Jun 24, 2025
6a5f5f3
Merge pull request #1 from Trozz/add_scheduler_feature
Trozz Jun 25, 2025
d9ba113
Merge pull request #23 from Trozz/main
eyarz Jun 26, 2025
7f254f2
Create Dockerfile for the tool to run inside K8s using CronJob
blufor Jun 26, 2025
be06e53
Merge pull request #24 from blufor/master
eyarz Jun 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ test.py
backups/*
!backups/.gitkeep
wizard.pyc
__pycache__/
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM python:3.8
COPY ./ /backup
RUN chown -R backup:backup /var/backups
WORKDIR /backup
RUN pip install -r requirements.txt
USER backup
ENTRYPOINT ["python", "backup.py"]
262 changes: 201 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,205 @@
# Jira Backup Python

[![datree-badge](https://s3.amazonaws.com/catalog.static.datree.io/datree-badge-28px.svg)](https://datree.io/?src=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:

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

# Installation
## Prerequisite:
:heavy_plus_sign: python 2.7.x or python 3.x.x
:heavy_plus_sign: [virtualenv](https://pypi.org/project/virtualenv/) installed globally (pip install virtualenv)

## Instructions:
1. Create and start [virtual environment](https://python-guide-cn.readthedocs.io/en/latest/dev/virtualenvs.html) (in this example, the virtualenv will be called "venv")
2. Install requirements
[![Python 3.7+](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A Python-based backup tool for Atlassian Cloud Jira and Confluence instances with multi-cloud storage support and automated scheduling.

## 🚀 Features

- **Jira & Confluence Backups**: Create backups for both Jira and Confluence Cloud instances
- **Multi-Cloud Support**: Stream backups directly to AWS S3, Google Cloud Storage, or Azure Blob Storage
- **Local Download**: Option to download backup files locally
- **Cross-Platform Scheduling**: Automatically create cron jobs (Linux/macOS) or scheduled tasks (Windows)
- **Configuration Wizard**: Interactive setup for easy configuration
- **API Token Authentication**: Secure authentication using Atlassian API tokens

## 📋 Prerequisites

- Python 3.7 or higher
- Atlassian Cloud account (Jira and/or Confluence)
- API token from [Atlassian](https://id.atlassian.com/manage/api-tokens)
- (Optional) Cloud storage account: AWS, Google Cloud, or Azure

## 🛠️ Installation

1. **Clone the repository**
```bash
git clone https://github.com/yourusername/jira-backup-py.git
cd jira-backup-py
```

2. **Create a virtual environment**
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```

3. **Install dependencies**
```bash
pip install -r requirements.txt
```

4. **Generate API token**
- Go to [Atlassian API Tokens](https://id.atlassian.com/manage/api-tokens) and create a token

5. **Configure the application**
- Create a `config.yaml` file with your settings (see Configuration section below)
- Or run the configuration wizard: `python backup.py -w`

## ⚙️ Configuration

### Configuration File Setup

Create a `config.yaml` file with your settings:

```yaml
---
HOST_URL: "your-instance.atlassian.net"
USER_EMAIL: "[email protected]"
API_TOKEN: "your-api-token"
INCLUDE_ATTACHMENTS: false
DOWNLOAD_LOCALLY: true

# AWS S3 Configuration (optional)
UPLOAD_TO_S3:
S3_BUCKET: "my-backup-bucket"
AWS_ACCESS_KEY_ID: "your-access-key"
AWS_SECRET_ACCESS_KEY: "your-secret-key"
AWS_S3_REGION: "us-east-1"

# Google Cloud Storage Configuration (optional)
UPLOAD_TO_GCP:
GCP_PROJECT_ID: "my-project-id"
GCS_BUCKET: "my-backup-bucket"
GCP_SERVICE_ACCOUNT_KEY: "/path/to/service-account-key.json"

# Azure Blob Storage Configuration (optional)
UPLOAD_TO_AZURE:
AZURE_ACCOUNT_NAME: "mystorageaccount"
AZURE_CONTAINER: "my-backup-container"
AZURE_CONNECTION_STRING: "DefaultEndpointsProtocol=https;AccountName=..."
# OR use AZURE_ACCOUNT_KEY instead of connection string
# AZURE_ACCOUNT_KEY: "your-account-key"
```
$(venv) pip install -r requirements.txt
```
3. Generate an API token at https://id.atlassian.com/manage/api-tokens
![Screenshot](https://github.com/datreeio/jira-backup-py/blob/master/screenshots/atlassian-api-token.png)
4. Fill the details at the [config.yaml file](https://github.com/datreeio/jira-backup-py/blob/master/config.json) or run the backup.py script with '-w' flag
5. Run backup.py script with the flag '-j' to backup Jira or '-c' to backup Confluence

### Configuration Wizard

For interactive setup, run:
```bash
python backup.py -w
```
$(venv) python backup.py
```
![Screenshot](https://github.com/datreeio/jira-backup-py/blob/master/screenshots/terminal.png)

## What's next?
It depends on your needs. I, for example, use this script together with [serverless](https://serverless.com/) to create a periodic [AWS lambda](https://aws.amazon.com/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

This will guide you through setting up basic Jira credentials and S3 configuration.

## 🚀 Usage

### Manual Backup

```bash
# Backup Jira (default)
python backup.py -j

# Backup Confluence
python backup.py -c

# Run configuration wizard
python backup.py -w
```
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](https://confluence.atlassian.com/cloud/api-tokens-938839638.html), instead personal Jira user name and password

# Resources:
:heavy_plus_sign: [JIRA support - How to Automate Backups for JIRA Cloud applications](https://confluence.atlassian.com/jirakb/how-to-automate-backups-for-jira-cloud-applications-779160659.html)
:heavy_plus_sign: [Atlassian Labs' automatic-cloud-backup script](https://bitbucket.org/atlassianlabs/automatic-cloud-backup/src/d43ca5f33192e78b2e1869ab7c708bb32bfd7197/backup.ps1?at=master&fileviewer=file-view-default)
:heavy_plus_sign: [A more maintainable version of Atlassian Labs' script](https://github.com/mattock/automatic-cloud-backup)

### Automated Scheduling

Set up scheduled backups using system schedulers:

```bash
# Setup automated Jira backup every 4 days at 10:00 AM (default)
python backup.py -s

# Setup automated Confluence backup every 7 days at 2:30 PM
python backup.py -s --schedule-days 7 --schedule-time 14:30 --schedule-service confluence

# Setup automated Jira backup every 2 days at 6:00 AM
python backup.py -s --schedule-days 2 --schedule-time 06:00 --schedule-service jira
```

This will create:
- **Linux/macOS**: A cron job in your crontab
- **Windows**: A scheduled task in Task Scheduler

### Command Line Options

| Option | Description |
|--------|-------------|
| `-j, --jira` | Backup Jira (default if no service specified) |
| `-c, --confluence` | Backup Confluence |
| `-w, --wizard` | Run configuration wizard |
| `-s, --schedule` | Setup automated scheduled backup |
| `--schedule-days` | Frequency in days for scheduled backup (default: 4) |
| `--schedule-time` | Time for scheduled backup in HH:MM format (default: 10:00) |
| `--schedule-service` | Service for scheduled backup (jira/confluence, default: jira) |

## 🔧 Advanced Configuration

### Minimal Configuration

If you only want to download backups locally without cloud storage:

```yaml
---
HOST_URL: "your-instance.atlassian.net"
USER_EMAIL: "[email protected]"
API_TOKEN: "your-api-token"
INCLUDE_ATTACHMENTS: false
DOWNLOAD_LOCALLY: true
```

Simply omit the `UPLOAD_TO_XXX` sections you don't need.

### Multiple Cloud Providers

You can configure multiple cloud storage providers simultaneously - the script will upload to all configured destinations:

```yaml
UPLOAD_TO_S3:
S3_BUCKET: "my-s3-bucket"
# ... S3 config

UPLOAD_TO_GCP:
GCS_BUCKET: "my-gcs-bucket"
# ... GCP config

UPLOAD_TO_AZURE:
AZURE_CONTAINER: "my-azure-container"
# ... Azure config
```

## 🤝 Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

## 📝 Changelog

- **2025-06-24**: Added separate cron schedules for Jira and Confluence backups
- **2025-06-24**: Made cloud storage configuration sections optional
- **2025-06-24**: Added automated scheduling support for backup tasks
- **2025-06-23**: Added Google Cloud Storage and Azure Blob Storage support
- **2020-09-04**: Added Confluence backup support
- **2019-01-16**: Updated to use API tokens instead of passwords

## 📜 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🙏 Acknowledgments

- Original concept inspired by [Atlassian Labs' automatic-cloud-backup](https://bitbucket.org/atlassianlabs/automatic-cloud-backup/)
- Thanks to all contributors who have helped improve this project

## 📞 Support

- **Issues**: [GitHub Issues](https://github.com/yourusername/jira-backup-py/issues)

---

**Note**: This tool is not officially supported by Atlassian. Use at your own risk and always verify your backups are working correctly.
Empty file removed __init__.py
Empty file.
Loading