• Stars
    star
    445
  • Rank 98,085 (Top 2 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 15 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

simple backup for mysql, posgresql, svn and files to s3 or local filesystem

astrails-safe

Simple database and filesystem backups with S3 and Rackspace Cloud Files support (with optional encryption)

Build Status Code Climate

Motivation

We needed a backup solution that will satisfy the following requirements:

  • opensource
  • simple to install and configure
  • support for simple ‘tar’ backups of directories (with includes/excludes)
  • support for simple mysqldump of mysql databases
  • support for symmetric or public key encryption
  • support for local filesystem, Amazon S3, and Rackspace Cloud Files for storage
  • support for backup rotation. we don’t want backups filling all the diskspace or cost a fortune on S3 or Cloud Files

And since we didn't find any, we wrote our own :)

Contributions

The following functionality was contributed by astrails-safe users:

Thanks to all :)

Installation

sudo gem install astrails-safe --source http://gemcutter.org

Reporting problems

Please report problems at the Issues tracker

Usage

Usage:
   astrails-safe [OPTIONS] CONFIG_FILE
Options:
  -h, --help           This help screen
  -v, --verbose        be verbose, duh!
  -n, --dry-run        just pretend, don't do anything.
  -L, --local          skip remote storage, only do local backups

Note: CONFIG_FILE will be created from template if missing

Encryption

If you want to encrypt your backups you have 2 options:

  • use simple password encryption
  • use GPG public key encryption

IMPORTANT: some gpg installations automatically set 'use-agent' option in the default configuration file that is created when you run gpg for the first time. This will cause gpg to fail on the 2nd run if you don't have the agent running. The result is that 'astrails-safe' will work ONCE when you manually test it and then fail on any subsequent run. The solution is to remove the 'use-agent' from the config file (usually /root/.gnupg/gpg.conf) To mitigate this problem for the gpg 1.x series '--no-use-agent' option is added by defaults to the autogenerated config file, but for gpg2 is doesn't work. as the manpage says it: "This is dummy option. gpg2 always requires the agent." :(

For simple password, just add password entry in gpg section. For public key encryption you will need to create a public/secret keypair.

We recommend to create your GPG keys only on your local machine and then transfer your public key to the server that will do the backups.

This way the server will only know how to encrypt the backups but only you will be able to decrypt them using the secret key you have locally. Of course you MUST backup your backup encryption key :) We recommend also pringing the hard paper copy of your GPG key 'just in case'.

The procedure to create and transfer the key is as follows:

  1. run 'gpg --gen-key' on your local machine and follow onscreen instructions to create the key (you can accept all the defaults).

  2. extract your public key into a file (assuming you used [email protected] as your key email): gpg -a --export [email protected] > [email protected]

  3. transfer public key to the server scp [email protected] [email protected]:

  4. import public key on the remote system:

    $ gpg --import [email protected] gpg: key 45CA9403: public key "Test Backup [email protected]" imported gpg: Total number processed: 1 gpg: imported: 1

  5. since we don't keep the secret part of the key on the remote server, gpg has no way to know its yours and can be trusted. To fix that we can sign it with other trusted key, or just directly modify its trust level in gpg (use level 5):

    $ gpg --edit-key [email protected] ... Command> trust ... 1 = I don't know or won't say 2 = I do NOT trust 3 = I trust marginally 4 = I trust fully 5 = I trust ultimately m = back to the main menu

    Your decision? 5 ... Command> quit

  6. export your secret key for backup (we recommend to print it on paper and burn to a CD/DVD and store in a safe place):

    $ gpg -a --export-secret-key [email protected] > [email protected]

Example configuration

safe do
  verbose true

  local :path => "/backup/:kind/:id"

  s3 do
    key "...................."
    secret "........................................"
    bucket "backup.astrails.com"
    path "servers/alpha/:kind/:id"
  end

  cloudfiles do
    user "..........."
    api_key "................................."
    container "safe_backup"
    path ":kind/" # this is default
    service_net false
  end

  sftp do
    host "sftp.astrails.com"
    user "astrails"
    # port 8023
    password "ssh password for sftp"
  end

  gpg do
    command "/usr/local/bin/gpg"
    options  "--no-use-agent"
    # symmetric encryption key
    # password "qwe"

    # public GPG key (must be known to GPG, i.e. be on the keyring)
    key "[email protected]"
  end

  keep do
    local 20
    s3 100
    cloudfiles 100
    sftp 100
  end

  mysqldump do
    options "-ceKq --single-transaction --create-options"

    user "root"
    password "............"
    socket "/var/run/mysqld/mysqld.sock"

    database :blog
    database :servershape
    database :astrails_com
    database :secret_project_com do
      skip_tables "foo"
      skip_tables ["bar", "baz"]
    end

  end

  svndump do
    repo :my_repo do
      repo_path "/home/svn/my_repo"
    end
  end

  pgdump do
    options "-i -x -O"   # -i => ignore version, -x => do not dump privileges (grant/revoke), -O => skip restoration of object ownership in plain text format

    user "username"
    password "............"  # shouldn't be used, instead setup ident.  Current functionality exports a password env to the shell which pg_dump uses - untested!

    database :blog
    database :stateofflux_com
  end

  tar do
    options "-h" # dereference symlinks
    archive "git-repositories", :files => "/home/git/repositories"
    archive "dot-configs",      :files => "/home/*/.[^.]*"
    archive "etc",              :files => "/etc", :exclude => "/etc/puppet/other"

    archive "blog-astrails-com" do
      files "/var/www/blog.astrails.com/"
      exclude "/var/www/blog.astrails.com/log"
      exclude "/var/www/blog.astrails.com/tmp"
    end

    archive "astrails-com" do
      files "/var/www/astrails.com/"
      exclude ["/var/www/astrails.com/log", "/var/www/astrails.com/tmp"]
    end
  end
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Copyright

Copyright (c) 2010-2013 Astrails Ltd. See LICENSE.txt for details.

More Repositories

1

dotvim

An attempt at The Ultimate Vim Configurationâ„¢ with focus on Rails development. DEPRECATED, SEE https://github.com/vitaly/dotvim2
Vim Script
549
star
2

clicktale

clicktale.com rails integration plugin
Ruby
33
star
3

smallrecord

Simple Object persistency library for Cassandra (ActiveRecord replacement for Rails)
Ruby
28
star
4

http_require

allow "require" from the web
Ruby
11
star
5

cshaml-sprockets

Use clientside-haml-js to render your haml templates with javascript/coffeescript and haml.
Ruby
10
star
6

rails_admin_impersonate

Impersonate as a Devise user for rails_admin
Ruby
10
star
7

mac-install

9
star
8

r2shell

Simple shell scripts with ruby
Ruby
4
star
9

active_merchant_tranzila

Tranzila gateway support for ActiveMerchant
Ruby
4
star
10

deb

Double Entry Bookkeeping for Rails
Ruby
4
star
11

popup-widget

A javascript library to create popup/popin widgets.
JavaScript
4
star
12

constfig

Constant Configuration from Environment for Ruby
Ruby
3
star
13

server-blender

Server provisioning and configuration management
Ruby
3
star
14

let_my_controller_go

Heretical assault on the MVC pattern. get access to your controller from models (or actually anywhere)
Ruby
3
star
15

server-blender-manifest

server-side root manifest implementation for server-blender
Ruby
2
star
16

vladify

collection of recipes and generators for super easy Rails deployment using "Vlad"
Ruby
2
star
17

benyehuda-cases-server

Ruby
2
star
18

global_preferences

simple plugin to manage global application preferences in the database
Ruby
2
star
19

sendgrid

using sendgrid with ActionMailer
Ruby
2
star
20

dotfiles

various conf files
Vim Script
2
star
21

request_logger

after_filter that logs request_information into the database
Ruby
2
star
22

dotzsh

zsh configs
Shell
2
star
23

astrails-form-builder

internal
Ruby
1
star
24

astrails-user-auth

internal
Ruby
1
star
25

astrails-spec-helpers

various helpers for rspec and skinny_spec. internal usage, not yet ready for release.
Ruby
1
star
26

resource-admin-controller

Ruby
1
star
27

automatic-po-files-translating

Ruby
1
star
28

restart_controller

Very simple controller to restart Passenger servers form the web by touching tmp/restart.txt
Ruby
1
star
29

react-presentation-flux-redux

JavaScript
1
star
30

once_in

Limit code block execution rate
Ruby
1
star
31

cellact

CellAct SMS plugin
Ruby
1
star
32

jumppad

our default Rails template for new projects.
Ruby
1
star
33

clickable-default-value

jQuery plugin adding form fields default values that disappear when the field focused
JavaScript
1
star
34

inherited_resources_pagination

paginate the default 'collection' helper in InheritedResources::Base
Ruby
1
star
35

netpay

NetPay.com Payments Gateway integration
Ruby
1
star
36

sun-ror-demo-java-image

Demo example source for Sun's JRuby on Rails with GlassFish Code Camp
Ruby
1
star
37

astrails-resource-controller

various changes to the resource_controller. internal usage. not ready for general consumtion :)
Ruby
1
star
38

google_analytics

just a simple helper "google_analytics" to integrate Google Analytics into your Rails application.
Ruby
1
star
39

sun-ror-demo-movie-db

Demo example source for Sun's JRuby on Rails with GlassFish Code Camp
Ruby
1
star