Skip to content

Commit

Permalink
Add a jira-backup puppet module
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelsey Hightower committed Jul 11, 2013
1 parent b11505b commit 2cb395d
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 48 deletions.
3 changes: 3 additions & 0 deletions Modulefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name 'jirabackup'
version '0.0.1'
source 'https://github.com/puppetlabs/jira-backup'
51 changes: 3 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,8 @@ A simple shell script to backup Jira instances according to Atlassian best pract
* Backup Jira attachments
* Backup Jira database using mysqldump

## Configuration
## jira-backup script

The jira-backup script requires the following configuration file:
Check the bin directory for more details on the `jira-backup` script

/etc/jira-backup.conf

If the configuration file is missing you will get the following error:

root@jira:~# jira-backup
Error: /etc/jira-backup.conf missing

root@jira:~# echo $?
1

An example configuration can be found in the configs directory.

## Installation

I'm in the process of creating a debian package for `jira-backup`, until then:

cp jira-backup /usr/local/bin/jira-backup
chmod +x /usr/local/bin/jira-backup

Then create the `/etc/jira-backup.conf` file.

vim /etc/jira-backup.conf

BACKUP_DIR='/var/atlassian/backups/jira'

# Attachments
ATTACHMENTS_PATH='/var/atlassian/application-data/jira/data/attachments'

# Database
DB_NAME='jira'
DB_HOST='database hostname'
DB_USER='jira'
DB_PASS='databae password'


## Usage

root@jira:~# /usr/local/bin/jira-backup
Backing up Jira
Backing up Jira attachments
/bin/tar: Removing leading `/' from member names
Created /var/atlassian/backups/jira/jira-attachments-2013-07-11-09-50.tar
Dumping Jira database
Created /var/atlassian/backups/jira/jira-database-dump-2013-07-11-09-50.sql

All backups end up under `/var/atlassian/backups`; this can be changed by setting the BACKUP_DIR in `/etc/jira-backup.conf`
## Puppet module
59 changes: 59 additions & 0 deletions bin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Jira Backup

A simple shell script to backup Jira instances according to Atlassian best practices outlined in [Backing Up Data](https://confluence.atlassian.com/display/JIRA052/Backing+Up+Data).

## Features

* Backup Jira attachments
* Backup Jira database using mysqldump

## Configuration

The jira-backup script requires the following configuration file:

/etc/jira-backup.conf

If the configuration file is missing you will get the following error:

root@jira:~# jira-backup
Error: /etc/jira-backup.conf missing

root@jira:~# echo $?
1

An example configuration can be found in the configs directory.

## Installation

I'm in the process of creating a debian package for `jira-backup`, until then:

cp jira-backup /usr/local/bin/jira-backup
chmod +x /usr/local/bin/jira-backup

Then create the `/etc/jira-backup.conf` file.

vim /etc/jira-backup.conf

BACKUP_DIR='/var/atlassian/backups/jira'

# Attachments
ATTACHMENTS_PATH='/var/atlassian/application-data/jira/data/attachments'

# Database
DB_NAME='jira'
DB_HOST='database hostname'
DB_USER='jira'
DB_PASS='databae password'


## Usage

root@jira:~# /usr/local/bin/jira-backup
Backing up Jira
Backing up Jira attachments
/bin/tar: Removing leading `/' from member names
Created /var/atlassian/backups/jira/jira-attachments-2013-07-11-09-50.tar
Dumping Jira database
Created /var/atlassian/backups/jira/jira-database-dump-2013-07-11-09-50.sql

All backups end up under `/var/atlassian/backups`; this can be changed by setting the BACKUP_DIR in `/etc/jira-backup.conf`
File renamed without changes.
61 changes: 61 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Class: jirabackup
#
# This class installs and configures the jira-backup utility
#
# Parameters:
#
# db_host: (default '')
# Set the mysql database host to connect to
#
# db_pass: (default '')
# Set the mysql database password
#
# db_user: (default 'jira')
# Set the mysql database user
#
# db_name: (default 'jira')
# Set the mysql database name
#
# backup_dir: (default '/var/atlassian/backups/jira')
# Set the target backup directory for Jira attachments and mysql dumps
#
# attachments_path: (default '/var/atlassian/application-data/jira/data/attachments')
# Set the path to the Jira attachments
#
# Actions:
# - Install jira-backup utility
# - Manage the jira-backup configuration settings
#
# Requires:
#
# Sample Usage:
#
# class { 'jirabackup':
# db_host => 'mysql.example.com',
# db_pass => 'database password',
# db_user => 'jira',
# db_name => 'jira',
# backup_dir => '/path/to/backup/output/dir',
# attachments_path => '/path/to/jira/attachments'
# }
#
class jirabackup (
$db_host,
$db_pass,
$db_user = 'jira',
$db_name = 'jira',
$backup_dir = '/var/atlassian/backups/jira',
$attachments_path = '/var/atlassian/application-data/jira/data/attachments',
){
package { 'jira-backup':
ensure => latest,
}

file { '/etc/jira-backup.conf'
ensure => present,
group => 'root',
owner => 'root',
mode => '0600',
content => template("jirabackup/jira-backup.conf.erb"),
}
}
10 changes: 10 additions & 0 deletions templates/jira-backup.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
BACKUP_DIR=<%= @backup_dir %>

# Attachments
ATTACHMENTS_PATH=<%= @attachments_path %>

# Database
DB_NAME=<%= @db_name %>
DB_HOST=<%= @db_host %>
DB_USER=<%= @db_user %>
DB_PASS=<%= @db_pass %>

0 comments on commit 2cb395d

Please sign in to comment.