public
Description: Rake and capistrano tasks to dump and restore db and assets
Homepage:
Clone URL: git://github.com/toy/dump.git
dump /
name age message
file .autotest Fri Jun 19 10:03:34 -0700 2009 added autospec matching (cap file rename in nex... [toy]
file .gitignore Thu Apr 23 18:57:38 -0700 2009 using sqlite :memory: db for tests [toy]
file README.rdoc Sun Oct 11 11:27:15 -0700 2009 variable explanations for all tasks [toy]
file Rakefile Sun Aug 23 10:08:49 -0700 2009 don't allow transfer to became stalled [toy]
file assets.example Sun Aug 16 18:09:09 -0700 2009 config[:assets] stores number of files as well ... [toy]
directory gems/ Sat Oct 10 13:23:09 -0700 2009 updated progress gem to 0.1.1.3 [toy]
file install.rb Sat Jul 04 15:20:42 -0700 2009 fixed install.rb [toy]
directory lib/ Wed Nov 25 05:43:48 -0800 2009 it seems that tap method did not exist in 2.2.2 [toy]
directory recipes/ Tue Dec 01 14:49:00 -0800 2009 fixing absent user issue [toy]
directory spec/ Sun Oct 11 11:37:51 -0700 2009 use true instead of 1 for SHOW_SIZE [toy]
directory tasks/ Sun Oct 11 11:37:15 -0700 2009 require dump_rake before dump_rake/env for asse... [toy]
README.rdoc

DumpRake

Tasks to create and restore dumps of selected files and database.

Install

  script/plugin install git://github.com/toy/dump.git

Put paths of dirs you want to dump in file config/assets.

Example

  public/audios
  public/flash
  public/images/upload
  public/videos

When using cap tasks — be sure to link dump folder to persistent place on deploy, or you will lose all dumps every deploy.

This plugin requires gems (but to reduce problems on shared hostings, unpacked versions of archive-tar-minitar-0.5.2 and progress-0.0.9.3 are used if they are not present):

  archive/tar/minitar
  progress (version 0.1.1 or later)

To install:

  gem install archive-tar-minitar progress

Capistrano integration

You can use cap dump:* tasks to control dumps on remote server. Don’t forget to deploy application to remote server before using dump:remote tasks. Also you can set custom remote rake binary in your deploy.rb like:

  set :rake, "/custom/rake"

Usage

  # create dump
  rake dump
  rake dump:create

  # list avaliable dumps
  rake dump:versions

  # restore dump
  rake dump:restore

  # delete old and unfinished dumps (all non tgz files will be deleted if they are not locked)
  rake dump:cleanup

Environment variables

While creating dumps:

DESC or DESCRIPTION — free form description of dump

  rake dump DESC='uploaded photos'

TAG or TAGS — comma separated list of tags

  rake dump TAGS='photos,videos'

ASSETS — comma or colon separated list of paths or globs to dump

  rake dump ASSETS='public/system:public/images/masks/*'
  rake dump ASSETS='public/system,public/images/masks/*'

TABLES — comma separated list of tables to dump or if prefixed by ’-’ — to skip; by default only sessions table is skipped; schema_info and schema_migrations are included in any case if they are present

dump all tables except sessions

  rake dump

dump all tables

  rake dump TABLES='-'

dump only people, pages and photos tables

  rake dump TABLES='people,pages,photos'

dump all tables except people and pages

  rake dump TABLES='-people,pages'

While restoring dumps:

LIKE, VER, VERSION — filter dumps by full dump name

  rake dump:versions LIKE='2009'
  rake dump:restore LIKE='2009' # restores last dump matching 2009

TAG or TAGS — comma separated list of tags without ’+’ or ’-’ — dump should have any of such tags prefixed with ’+’ — dump should have every tag with prefix prefixed with ’-’ — dump should not have any of tags with prefix

select dumps with tags photos or videos:

  rake dump:restore TAGS='photos,videos'

select dumps with tags photos and videos:

  rake dump:restore TAGS='+photos,+videos'

skip dumps with tags mirror and archive:

  rake dump:restore TAGS='-mirror,-archive'

select dumps with tags photos or videos, with tag important and without mirror:

  rake dump:restore TAGS='photos,videos,+important,-mirror'

For listing dumps:

LIKE, VER, VERSION and TAG or TAGS — as for restoring

SUMMARY — output info about dump

  rake dump:versions SUMMARY=1
  rake dump:versions SUMMARY=full # output schema too

For cleanup:

LIKE, VER, VERSION and TAG or TAGS — as for restoring

LEAVE — number of dumps to leave

  rake dump:cleanup LEAVE=10
  rake dump:cleanup LEAVE=none

cap tasks

For all cap commands environment variables are same as for rake tasks

Basic cap tasks are same as rake tasks

  cap dump:local
  cap dump:local:create
  cap dump:local:restore
  cap dump:local:versions
  cap dump:local:cleanup

  cap dump:remote
  cap dump:remote:create
  cap dump:remote:restore
  cap dump:remote:versions
  cap dump:remote:cleanup

Dump exchanging tasks

transfer selected dump to remote server:

  cap dump:local:upload

transfer selected dump to local:

  cap dump:remote:download

mirror local to remote (create local dump, upload it to remote and restore it there):

  cap dump:mirror:up

mirror remote to local (create remote dump, download it from remote and restore on local):

  cap dump:mirror:down

If you are sure that there is no need for autobackup — pass BACKUP, AUTOBACKUP or AUTO_BACKUP with 0, or something starting with n or f

  cap dump:mirror:down BACKUP=0
  cap dump:mirror:down AUTOBACKUP=no
  cap dump:mirror:down AUTO_BACKUP=false

backup remote on local (create remote dump and download it):

  cap dump:backup

Transferring task will try to transfer using rsync if it is present, else it will try to use sftp and scp You can skip those tries if you set TRANSFER_VIA to rsync, sftp or scp

  cap dump:backup TRANSFER_VIA=rsync
  cap dump:mirror:up TRANSFER_VIA=scp