Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding cron recipe to setup regular backups #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 30 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Requirements

## Cookbooks:

This cookbook depends on the following cookbooks:

* cron

This cookbook recommends on the following cookbooks:

* mysql
Expand All @@ -22,15 +26,18 @@ This cookbook recommends on the following cookbooks:

* Debian
* Ubuntu
* CentOS
* RHEL

Attributes
==========

## repository.rb:
### repository.rb:

* `node['hollandbackup']['repository']['distro']` - The Linux distro, defaults to "xUbuntu_12.04"
* `node['hollandbackup']['repository']['distro']` - The Linux distro to use, check the [openSUSE repositories](http://download.opensuse.org/repositories/home:/holland-backup/) for the proper name for your distro

## mysqldump.rb: (see http://docs.hollandbackup.org/provider_configs/mysqldump.html)
### mysqldump.rb:
* See http://docs.hollandbackup.org/provider_configs/mysqldump.html

### general
* `node['hollandbackup']['mysqldump']['mysql_binpath']` - see Holland Backup mysqldump-docs, defaults to nil
Expand All @@ -52,7 +59,7 @@ Attributes
* `node['hollandbackup']['mysqldump']['filtering']['tables']` - see Holland Backup mysqldump-docs, defaults to nil
* `node['hollandbackup']['mysqldump']['filtering']['exclude_tables']` - see Holland Backup mysqldump-docs, defaults to nil

### [compression]
#### [compression]
* `node['hollandbackup']['mysqldump']['compresssion']['method']` - see Holland Backup mysqldump-docs, defaults to nil
* `node['hollandbackup']['mysqldump']['compresssion']['inline']` - see Holland Backup mysqldump-docs, defaults to nil
* `node['hollandbackup']['mysqldump']['compresssion']['level']` - see Holland Backup mysqldump-docs, defaults to nil
Expand All @@ -66,22 +73,34 @@ Attributes
* `node['hollandbackup']['mysqldump']['mysql_connection']['host']` - see Holland Backup mysqldump-docs, defaults to nil
* `node['hollandbackup']['mysqldump']['mysql_connection']['port']` - see Holland Backup mysqldump-docs, defaults to nil

## main.rb: (see http://docs.hollandbackup.org/config.html#holland-conf-main-config)
### [holland]
### main.rb:
* See http://docs.hollandbackup.org/config.html#holland-conf-main-config

#### [holland]
* `node['hollandbackup']['main']['plugin_dirs']` - see Holland Backup main config-docs, defaults to nil
* `node['hollandbackup']['main']['backup_directory']` - see Holland Backup main config-docs, defaults to nil
* `node['hollandbackup']['main']['backupsets']` - see Holland Backup main config-docs, defaults to nil
* `node['hollandbackup']['main']['umask']` - see Holland Backup main config-docs, defaults to nil
* `node['hollandbackup']['main']['path']` - see Holland Backup main config-docs, defaults to nil

### [logging]
#### [logging]
* `node['hollandbackup']['main']['filename']` - see Holland Backup main config-docs, defaults to nil
* `node['hollandbackup']['main']['level']` - see Holland Backup main config-docs, defaults to nil

## backupsets.rb:
### backupsets.rb:

* `node['hollandbackup']['backupsets']` - A list of backupsets

### cron.rb:
The `hollandbackup::cron` recipe leverages the [cron lwrp](https://github.com/opscode-cookbooks/cron#resources-and-providers):
* `node['hollandbackup']['cron']['minute']` - Minute to run hollandbackup, defaults to `0`
* `node['hollandbackup']['cron']['hour']` - Hour to run hollandbackup, defaults to `3`
* `node['hollandbackup']['cron']['day']` - Day to run hollandbackup, defaults to `*`
* `node['hollandbackup']['cron']['month']` - Month to run hollandbackup, defaults to `*`
* `node['hollandbackup']['cron']['weekday']` - Weekday to run hollandbackup, defaults to `*`
* `node['hollandbackup']['cron']['user']` - User to run backup as, defaults to `root`
* `node['hollandbackup']['cron']['command']` - Command to run during backup, defaults to `holland -q backup`

Usage
=====

Expand All @@ -93,6 +112,8 @@ Usage
--- OR ---
override the attribute on a higher level (http://wiki.opscode.com/display/chef/Attributes#Attributes-AttributesPrecedence)

Optionally add `recipe[hollandbackup::cron]` to setup a cron job to run backups.

References
==========

Expand Down Expand Up @@ -129,4 +150,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
13 changes: 13 additions & 0 deletions attributes/cron.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# Cookbook Name:: hollandbackup
# Attributes:: cron
#

default['hollandbackup']['cron']['minute'] = '0'
default['hollandbackup']['cron']['hour'] = '3'
default['hollandbackup']['cron']['day'] = '*'
default['hollandbackup']['cron']['month'] = '*'
default['hollandbackup']['cron']['weekday'] = '*'

default['hollandbackup']['cron']['user'] = 'root'
default['hollandbackup']['cron']['command'] = '/usr/sbin/holland -q backup'
11 changes: 10 additions & 1 deletion attributes/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@
# Copyright 2012-2014, David Joos
#

default['hollandbackup']['repository']['distro'] = "xUbuntu_12.04"
case node['platform']
when 'ubuntu'
default['hollandbackup']['repository']['distro'] = "xUbuntu_#{node['platform_version']}"
when 'centos'
default['hollandbackup']['repository']['distro'] = "CentOS_CentOS-#{node['platform_version'].to_i}"
when 'debian'
default['hollandbackup']['repository']['distro'] = "Debian_#{node['platform_version'].to_i}.0"
when 'rhel'
default['hollandbackup']['repository']['distro'] = "RedHat_RHEL-#{node['platform_version'].to_i}"
end
9 changes: 6 additions & 3 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.1.0"

%w{ debian ubuntu }.each do |os|
supports os
%w{ debian ubuntu rhel centos }.each do |os|
supports os
end

recommends "mysql"

depends "cron"

recipe "hollandbackup", "Adds the Holland Backup repository."
recipe "hollandbackup::repository", "Adds the Holland Backup repository."
recipe "hollandbackup::mysqldump", "Installs & configures the Holland Backup mysqldump provider."
recipe "hollandbackup::main", "Configures the main Holland Backup settings."
recipe "hollandbackup::backupsets", "Configures the Holland Backup backupset(s) settings."
recipe "hollandbackup::backupsets", "Configures the Holland Backup backupset(s) settings."
recipe "hollandbackup::cron", "Sets up a cron job to automatically run backups."
14 changes: 14 additions & 0 deletions recipes/cron.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Cookbook Name:: hollandbackup
# Recipe:: cron
#

cron_d 'holland-backup' do
minute node['hollandbackup']['cron']['minute']
hour node['hollandbackup']['cron']['hour']
day node['hollandbackup']['cron']['day']
month node['hollandbackup']['cron']['month']
weekday node['hollandbackup']['cron']['weekday']
command node['hollandbackup']['cron']['command']
user node['hollandbackup']['cron']['user']
end
7 changes: 5 additions & 2 deletions recipes/mysqldump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

package "holland-mysqldump" do
action :upgrade
options "--force-yes"
case node['platform_family']
when 'debian'
options "--force-yes"
end
end

hollandbackup_mysqldump "holland-configure-mysqldump-provider" do
Expand Down Expand Up @@ -43,4 +46,4 @@
socket node['hollandbackup']['mysqldump']['mysql_connection']['socket']
host node['hollandbackup']['mysqldump']['mysql_connection']['host']
port node['hollandbackup']['mysqldump']['mysql_connection']['port']
end
end
17 changes: 16 additions & 1 deletion recipes/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,19 @@
command "apt-get update"
action :nothing
end
end
when 'centos', 'rhel'
distro = node['hollandbackup']['repository']['distro']

package 'yum-utils'

execute "hollandbackup-yum-repo-setup" do
command "yum-config-manager --add-repo http://download.opensuse.org/repositories/home:/holland-backup/#{distro}/home:holland-backup.repo"
notifies :run, "execute[hollandbackup-yum-makecache]", :immediately
end

#update the local package list
execute "hollandbackup-yum-makecache" do
command "yum makecache"
action :nothing
end
end