Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
Merge branch 'feature/add_backup' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
PanfilovDenis committed Feb 19, 2013
2 parents 458b02e + bd825ab commit 97eec27
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ gem 'google-analytics-rails'
gem 'validates'
gem 'virtus'
gem 'js-routes'
gem 'backup'
gem 'whenever'

# Gems used only for assets and not required
# in production environments by default.
Expand Down
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ GEM
ansi (1.4.3)
arel (3.0.2)
backports (2.6.7)
backup (3.0.27)
open4 (~> 1.3.0)
thor (>= 0.15.4, < 2)
bcrypt-ruby (3.0.1)
builder (3.0.4)
capistrano (2.14.1)
Expand All @@ -49,6 +52,7 @@ GEM
carrierwave (0.6.2)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
chronic (0.8.0)
ci_reporter (1.8.3)
builder (>= 2.1.2)
ckeditor (3.7.3)
Expand Down Expand Up @@ -130,6 +134,7 @@ GEM
net-ssh (2.6.3)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
open4 (1.3.0)
orm_adapter (0.4.0)
pg (0.14.1)
polyglot (0.3.3)
Expand Down Expand Up @@ -228,6 +233,9 @@ GEM
virtus (0.5.4)
backports (~> 2.6.1)
descendants_tracker (~> 0.0.1)
whenever (0.8.0)
activesupport (>= 2.3.4)
chronic (>= 0.6.3)
ya_acl (0.0.7)
rake

Expand All @@ -236,6 +244,7 @@ PLATFORMS

DEPENDENCIES
airbrake
backup
bcrypt-ruby (~> 3.0.0)
capistrano
capistrano-ext
Expand Down Expand Up @@ -277,4 +286,5 @@ DEPENDENCIES
usefull_scopes
validates
virtus
whenever
ya_acl
47 changes: 47 additions & 0 deletions config/backup.rb.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# encoding: utf-8

##
# Backup Generated: backup
# Once configured, you can run the backup with the following command:
#
# $ backup perform -t backup [-c <path_to_configuration_file>]
#
Backup::Model.new(:nastachku_staging, 'Nastachku staging backup') do

database PostgreSQL do |db|
db.name = "nastachku_staging"
db.username = "nastachku_staging"
db.password = "password"
end

store_with Local do |local|
local.path = "/var/tmp/"
local.keep = 5
end

compress_with Gzip do |compression|
compression.best = true
compression.fast = false
end

end

Backup::Model.new(:nastachku_production, 'Nastachku production backup') do

database PostgreSQL do |db|
db.name = "nastachku_production"
db.username = "nastachku_production"
db.password = "password"
end

store_with Local do |local|
local.path = "/var/tmp/"
local.keep = 18
end

compress_with Gzip do |compression|
compression.best = true
compression.fast = false
end

end
7 changes: 7 additions & 0 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
task :symlink_db, :roles => :app do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end

desc "Symlinks the backup.rb"
task :symlink_backup, :roles => :app do
run "ln -nfs #{shared_path}/config/backup.rb #{release_path}/config/backup.rb"
end

desc "Seed database data"
task :seed_data do
run "cd #{current_path} && RAILS_ENV=#{rails_env} #{rake} db:seed"
Expand All @@ -27,5 +33,6 @@
end

before 'deploy:finalize_update', 'deploy:symlink_db'
after 'deploy:symlink_db', 'deploy:symlink_backup'
after "deploy:update", "deploy:cleanup"
after 'deploy:restart', 'unicorn:stop'
5 changes: 4 additions & 1 deletion config/deploy/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@

role :web, '62.76.184.142'
role :app, '62.76.184.142'
role :db, '62.76.184.142', :primary => true
role :db, '62.76.184.142', :primary => true

set :whenever_command, "bundle exec whenever"
require "whenever/capistrano"
29 changes: 29 additions & 0 deletions config/schedule.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use this file to easily define all of your cron jobs.
#
# It's helpful, but not entirely necessary to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron

# Example:
#
# set :output, "/path/to/my/cron_log.log"
#
# every 2.hours do
# command "/usr/bin/some_great_command"
# runner "MyModel.some_method"
# rake "some:great:rake:task"
# end
#
# every 4.days do
# runner "AnotherModel.prune_old_records"
# end

# Learn more: http://github.com/javan/whenever

job_type :bundle_command, "cd :path && RAILS_ENV=#{environment} bundle exec :task"

set :path, "/u/apps/nastachku/current"

every 4.hours do
bundle_command "backup perform -t nastachku_#{environment} -c config/backup.rb --root_path ."

end

0 comments on commit 97eec27

Please sign in to comment.