capobvious 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -38,7 +38,7 @@ run rake db:seed with right RAILS_ENV
38
38
  import remote server postgresql database to your development postgresql database IT WILL DELETE YOUR DEV DATABASE (NOTE: need installed p7zip)
39
39
 
40
40
 
41
- r**ake TASK=db:seed**
41
+ **rake TASK=db:seed**
42
42
  runs custom rake task
43
43
 
44
44
 
data/bin/capobvious CHANGED
@@ -52,6 +52,7 @@ set :user, "USER_NAME_HERE"
52
52
  set :serv, "IP_ADDRESS_HERE"
53
53
 
54
54
  set :repository, "REPOSITORY_HERE"
55
+ set :branch, "master"
55
56
  set :server_name, "example.com"
56
57
  set :server_redirect, "www.example.com"
57
58
 
@@ -60,12 +61,19 @@ set :backup_db, false
60
61
  set :backup_sys, false
61
62
  set :auto_migrate, true
62
63
 
64
+ #set :deploy_to, "/home/user/www/application"
65
+ set :deploy_via, :remote_cache
66
+
67
+ set :keep_releases, 5
68
+ set :use_sudo, false
69
+
70
+ set :scm, :git
63
71
 
64
72
  role :app, serv
65
73
  role :web, serv
66
74
  role :db, serv, :primary => true
67
75
  FILE
68
- "config/unicorn.rb" => <<FILE
76
+ "config/unicorn.rb" => <<FILE
69
77
  # -*- encoding : utf-8 -*-
70
78
  APP_PATH = File.expand_path(File.dirname(File.dirname(__FILE__)))
71
79
  SHARED_PATH = File.expand_path(APP_PATH+"/../shared")
@@ -91,7 +99,7 @@ SHARED_PATH = File.expand_path(APP_PATH+"/../shared")
91
99
 
92
100
 
93
101
  before_exec do |server|
94
- ENV["BUNDLE_GEMFILE"] = APP_PATH}+"/Gemfile"
102
+ ENV["BUNDLE_GEMFILE"] = APP_PATH+"/Gemfile"
95
103
  end
96
104
 
97
105
  before_fork do |server, worker|
@@ -48,12 +48,14 @@ Capistrano::Configuration.instance.load do
48
48
 
49
49
  set :local_folder_path, "tmp/backup"
50
50
  set :timestamp, Time.new.to_i.to_s
51
+ set :db_archive_ext, "tar.bz2"
52
+ set :arch_extract, "tar -xvjf"
53
+ set :arch_create, "tar -cjf"
54
+
51
55
  set :db_file_name, "#{database}-#{timestamp}.sql"
52
- set :db_archive_ext, "7z"
53
56
  set :sys_file_name, "#{application}-system-#{timestamp}.#{db_archive_ext}"
57
+ set :del_backup, true
54
58
 
55
- set :arch_extract, "7z x"
56
- set :arch_create, "7z a"
57
59
 
58
60
 
59
61
  #after "deploy:symlink", "auto:run"
@@ -235,24 +237,32 @@ Capistrano::Configuration.instance.load do
235
237
  file_name = fetch(:db_file_name)
236
238
  archive_ext = fetch(:db_archive_ext)
237
239
  dump_file_path = "#{shared_path}/backup/#{file_name}"
238
- output_file = "#{dump_file_path}.#{archive_ext}"
240
+ output_file = "#{file_name}.#{archive_ext}"
241
+ output_file_path = "#{dump_file_path}.#{archive_ext}"
239
242
  require 'yaml'
240
243
  run "mkdir -p #{shared_path}/backup"
241
244
  if adapter == "postgresql"
242
-
245
+ logger.important("Backup database #{database}", "Backup:db")
243
246
  run "export PGPASSWORD=\"#{db_password}\" && pg_dump -U #{db_username} #{database} > #{dump_file_path}"
244
- run "cd #{shared_path} && #{arch_create} #{output_file} #{dump_file_path} && rm #{dump_file_path}"
247
+ run "cd #{shared_path}/backup && #{arch_create} #{output_file} #{file_name} && rm #{dump_file_path}"
245
248
  else
246
249
  puts "Cannot backup, adapter #{adapter} is not implemented for backup yet"
247
250
  end
248
251
  system "mkdir -p #{local_folder_path}"
249
- download(output_file, "#{local_folder_path}/#{file_name}.#{archive_ext}")
252
+ download_path = "#{local_folder_path}/#{file_name}.#{archive_ext}"
253
+ logger.important("Downloading database to #{download_path}", "Backup:db")
254
+ download(output_file_path, download_path)
255
+ run "rm -v #{output_file_path}" if fetch(:del_backup)
250
256
  end
251
257
  desc "Backup public/system folder"
252
258
  task :sys do
253
259
  file_path = "#{shared_path}/backup/#{sys_file_name}"
254
- run "#{arch_create} #{file_path} #{shared_path}/system"
255
- download(file_path, "#{local_folder_path}/#{sys_file_name}")
260
+ logger.important("Backup shared/system folder", "Backup:sys")
261
+ run "#{arch_create} #{file_path} -C #{shared_path} system"
262
+ download_path = "#{local_folder_path}/#{sys_file_name}"
263
+ logger.important("Downloading system to #{download_path}", "Backup:db")
264
+ download(file_path, download_path)
265
+ run "rm -v #{file_path}" if fetch(:del_backup)
256
266
  end
257
267
  task :all do
258
268
  backup.db
@@ -473,4 +483,10 @@ Capistrano::Configuration.instance.load do
473
483
  unicorn.restart
474
484
  end
475
485
  end
486
+
487
+
488
+ def file_size(file_path)
489
+ size = run("wc -c #{file_path} | cut -d' ' -f1")
490
+ return size
491
+ end
476
492
  end
@@ -1,3 +1,3 @@
1
1
  module Capobvious
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capobvious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-22 00:00:00.000000000 Z
12
+ date: 2012-06-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  version: '0'
80
80
  requirements: []
81
81
  rubyforge_project: capobvious
82
- rubygems_version: 1.8.23
82
+ rubygems_version: 1.8.24
83
83
  signing_key:
84
84
  specification_version: 3
85
85
  summary: Cap recipes