Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status

RSS

backup_lwrp (12) Versions 0.4.0

Installs/Configures backup

Policyfile
Berkshelf
Knife
cookbook 'backup_lwrp', '~> 0.4.0', :supermarket
cookbook 'backup_lwrp', '~> 0.4.0'
knife supermarket install backup_lwrp
knife supermarket download backup_lwrp
README
Dependencies
Changelog
Quality 63%

Backup Cookbook

Build Status

This cookbook automates deploying the backup gem and the configuration of any models you may want. With a little work you can backup everything using this cookbook as the framework.

Requirements

packages

  • ruby - ruby is required for the backup gem to be installed. > Note Currently Chef13 ships Ruby 2.4 in it's Omnnibus which is not compatable with the Backup gem currently
  • libxml2-dev
  • libxslt1-dev

Resources and Providers

This cookbook provides three resources and corresponding providers.

install.rb

Install or Remove the backup gem with this resource.

Actions:

  • install - installs the backup gem
  • remove - removes the backup gem

generate_config.rb

Generate a configuration file for the backup gem with this resource.

Actions:

  • setup - sets up a basic config.rb for the backup gem
  • remove - removes the base directory for the backup gem and everything underneath it.

backup::install

Attribute Type Description Default Required
version String Version of the backup gem to install 4.4.0 No

backup::generate_config

Attribute Type Description Default Required
base_dir String Path where backup adn it's configuration files and models resize /opt/backup No
cookbook String Cookbook that has the erb template specified in the <code>source</code> to generate config.rb backup No
source String Filename of the erb template that generates <code>config.rb</code> config.rb.erb No
tmp_path String Directory to store temporary files during backup /tmp No
data_path String Directory to store Storage Cycler Yaml Files /opt/backup/.data No

backup::generate_model

Attribute Type Description Default Required
options Hash Specifies the options used in the backup model {} Yes
base_dir String Path where backup and it's configuration files and models reside /opt/backup No
gem_bin_dir String Path where gem binaries end up. (e.g. /usr/local/bin) No
split_into_chunks_of Fixnum Split the backup archives into multiple smaller files No
description String Description of the backup No
backup_type String What kind of backup? archive or database database Yes
database_type String Type of Database to backup Yes
encrypt_with Hash Hash to specify how to Encrypt No
compress_with String Specify the Comrpession Method (or disable it) Gzip
store_with Hash Specify what storage engines you wish use {} Yes
sync_with Hash Enable and configure syncers for this model.</td> {} No
hour String What hour to run the backup 1 No
minute String How many minutes past the hour to run the backup 0 No
month String Day of the month to run backup * No
weekday String Day of the week to run backup * No
mailto String sets the MAILTO variable in the crontab to specify who should get the output of the crontab run No
tmp_path String sets the tmp path for the backup No
cron_path String sets the PATH variable in the crontab No
cron_log String Log file for redirecting the job output No
before_hook String Before hook runs ruby code just after Backup logs that the backup has started, before any procedures are performed No
after_hook String After hook runs ruby code just before any Notifiers and is guranteed to run wether or not the backup process was successful or not No
notify_by Hash Hash object that configures Notifiers No
sync_with Hash Hash object that configures Syncers No
storage_class String Symbol that specifies the storage class with with S3 No

Usage

This cookbook is intended to be a framework to help backup your systems. Some examples below:

MongoDB

package "ruby-full"
backup_install node.name
backup_generate_config node.name
gem_package "fog" do
  version "~> 1.4.0"
end
backup_generate_model "mongodb" do
  description "Our shard"
  backup_type "database"
  database_type "MongoDB"
  split_into_chunks_of 2048
  store_with({"engine" => "S3", "settings" => { "s3.access_key_id" => "example", "s3.secret_access_key" => "sample", "s3.region" => "us-east-1", "s3.bucket" => "sample", "s3.path" => "/", "s3.keep" => 10 } } )
  options({"db.host" => "\"localhost\"", "db.lock" => true})
  mailto "some@example.com"
  cron_path "/bin:/usr/bin:/usr/local/bin"
  tmp_path "/mnt/backups"
  cron_log "/var/log/backups.log"
  action :backup
end

PostgreSQL

package "ruby-full"
backup_install node.name
backup_generate_config node.name
gem_package "fog" do
  version "~> 1.4.0"
end
backup_generate_model "pg" do
  description "backup of postgres"
  backup_type "database"
  database_type "PostgreSQL"
  split_into_chunks_of 2048
  store_with({"engine" => "S3", "settings" => { "s3.access_key_id" => "sample", "s3.secret_access_key" => "sample", "s3.region" => "us-east-1", "s3.bucket" => "sample", "s3.path" => "/", "s3.keep" => 10 } } )
  options({"db.name" => "\"postgres\"", "db.username" => "\"postgres\"", "db.password" => "\"somepassword\"", "db.host" => "\"localhost\"", "db.additional_options" => "[\" --format custom \"]"})
  mailto "sample@example.com"
  action :backup
end

Archiving files to S3

package "ruby-full"
backup_install node.name
backup_generate_config node.name
gem_package "fog" do
  version "~> 1.4.0"
end
backup_generate_model "home" do
  description "backup of /home"
  backup_type "archive"
  split_into_chunks_of 250
  store_with({"engine" => "S3", "settings" => { "s3.access_key_id" => "sample", "s3.secret_access_key" => "sample", "s3.region" => "us-east-1", "s3.bucket" => "sample", "s3.path" => "/", "s3.keep" => 10 } } )
  options({"add" => ["/home/","/root/"], "exclude" => ["/home/tmp"], "tar_options" => "-p"})
  mailto "sample@example.com"
  action :backup
end

Notifications

package "ruby-full"
backup_generate_model "archive_attribute_test" do
  description "backup of /etc using additional attributes"
  backup_type "archive"
  split_into_chunks_of 250
  store_with({"engine" => "Local", "settings" => { "local.keep" => 5, "local.path" => "/tmp" } })
  options({"add" => ["/home/","/etc/"], "exclude" => ["/etc/init"], "tar_options" => "-p"})
  mailto "sample@example.com"
  action :backup
  notify_by({"method" => "Campfire", "settings" => {"campfire.on_success" => "true", "campfire.on_warning" => "true", "campfire.on_failure" => "true", "campfire.api_token" => "token", "campfire.subdomain" => "domain", "campfire.room_id" => '34' }})
  gem_bin_dir "/usr/local/bin"
  cron_path "/bin:/usr/bin:/usr/local/bin:/opt/chef/embedded/bin"
  cron_log "/var/log/backups.log"
  tmp_path "/opt/tmp/backups"
end

Syncers

package "ruby-full"
backup_generate_model "sync_my_docs" do
  description  "Backup with RSync::Pull"
  action :backup
  backup_type "syncer"
  gem_bin_dir "/opt/chef/embedded/bin"
  options "add" => ["/home/username/documents", "/home/username/works"],
          "exclude" => ["tmp"]
  sync_with "syncer" => "RSync::Pull",
            "settings" => { "syncer.path" => "/opt/backup/syncs",
                            "syncer.mode" => :ssh,
                            "syncer.additional_ssh_options" => "-i /home/username/.ssh/id_rsa",
                            "syncer.host" => "192.168.0.42",
                            "syncer.ssh_user" => "username" }
end

It is possible to load the settings in an role or an data bag or leave the settings in a recipe.

License and Author

Author:: Scott Likens (scott@likens.us)

Copyright 2014-2017, Scott M. Likens

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Dependent cookbooks

build-essential >= 0.0.0
cron >= 0.0.0

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

Unreleased:

v0.4.0:

  • Update README to clarify that we need Ruby 2.3 or younger at the moment. This won't work with the Omnibus install of Chef currently.
  • Hardcode gem_bin_dir to /usr/local/bin
  • Remove unneccesary code from providers/generate_mode.rb Pull Request #54
  • Update Testing framework
  • Add basic tests for inspec

v0.3.4:

  • storage_class isn't in the right space. Make it work

v0.3.3:

  • Revert storage_class to a string so you can just use ":standard_ia" and it still is a symbol

v0.3.2:

  • Attempt to ensure storage_class is a symbol failed. .to_sym is not available

v0.3.1:

  • Add storage_class

v0.3.0:

  • Add Syncer support from pull request #41
  • Disable Compression by default

v0.2.6:

  • Modify cron_path so it has healthy defaults that should work.

v0.2.5:

  • Add compress_with to disable or change compression methods.

v0.2.4:

  • Improve testing material
  • Bump version to the latest version of the Backup gem
  • Include the dependencies it needs like zlib1g-dev and liblzma-dev (and centos varients)
  • Bump the centos version to 6.6

v0.2.3:

  • check if mailto is defined and if it's not that's fine.
  • support notifiers with notify_by

v0.2.2:

  • Bump the version of the backup gem to 4.1.1
  • after_hook was not being passed to the provider. It is now
  • node['languages']['ruby'] is not nil by default. This causes the crontab to generate the wrong command in error in certain situations.
  • Add Chef12 to the test-kitchen support lineup

v0.2.1:

  • Removes the old crontab generated by previous versions of the Cookbook

v0.2.0:

  • Move from crontab resource to cron_d
  • Fix a bug in generate_config that would prevent you from properly running ruby backup_generate_config "bob" do action :remove end
  • Improved the testing

v0.1.0:

  • Upgrade backup gem to 4.0.1
  • Moves /root/Backup/data to /opt/backup/.data to preserve Storage Cycler information.
  • Write config.rb in the new format minus preloading model definitions.
  • Moved encrypt_with out of the generate_config provider and moved it into the generate_model. See tests for working examples.
  • Update model template to support encrypt_with as well as minor cosmetic changes

v0.0.11:

  • Update providers/generate_model.rb that used the parameter remove in error; it should be delete.
  • Create test scenario to exercise this code

v0.0.10:

  • Remove references to require Chef11
  • Update reference to split_into_chunks_of as it is not set by default.
  • Update links to Backup documentation
  • Support before_hook and after_hook

v0.0.9:

  • Remove rescue blocks around use_inline_resources and test for its existiance.
  • added a test suite to verify the cookbook works still with chef10

v0.0.8:

  • Backup on minute 0. * would backup every minute at 1am
  • Enable s3_options which allows you to specify th S3 endpoint
store_with({"engine" => "S3", "settings" => { "s3.access_key_id" => "S3_ACCESS_KEY", "s3.secret_access_key" => "S3_SECRET_ACCESS_KEY", "s3.bucket" => "BUCKET", "s3.path" => "DIR", "s3.keep" => 5, "s3.fog_options" => {  :host => 's3.DUMMY.DOMAIN.COM', :scheme => 'http', :port => 80 } } } )
  action :backup
  • Removed blind rescue

v0.0.7:

  • Added whyrun support

v0.0.6:

  • Add Additional attributes for logging; cron path and where the gem binary is located.
  • Add Debian box to test-kitchen
  • Always manage cron instead of on just when creating the model

v0.0.5:

  • Improve README
  • Add Minitests
  • Use Inline Resources

v.0.04:

  • Convert to LWRP

v.0.0.3:

Fork from Heavywater

Collaborator Number Metric
            

0.4.0 failed this metric

Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.

Foodcritic Metric
            

0.4.0 failed this metric

FC064: Ensure issues_url is set in metadata: backup_lwrp/metadata.rb:1
FC065: Ensure source_url is set in metadata: backup_lwrp/metadata.rb:1
FC066: Ensure chef_version is set in metadata: backup_lwrp/metadata.rb:1
FC069: Ensure standardized license defined in metadata: backup_lwrp/metadata.rb:1
FC074: LWRP should use DSL to define resource's default action: backup_lwrp/resources/generate_config.rb:1
FC074: LWRP should use DSL to define resource's default action: backup_lwrp/resources/generate_model.rb:1
FC074: LWRP should use DSL to define resource's default action: backup_lwrp/resources/install.rb:1
FC121: Cookbook depends on cookbook made obsolete by Chef 14: backup_lwrp/metadata.rb:1
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any

No Binaries Metric
            

0.4.0 passed this metric