bonethug 0.0.20 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -60,6 +60,15 @@ argument*
60
60
 
61
61
 
62
62
 
63
+ **Trigger Backup on Local Copy**
64
+
65
+ *Uses astrails-safe to make a backup using the .bonethug/backup.rb file. Uses
66
+ the info contained in cnf.yml*
67
+
68
+ `bonethug backup {development|staging|production}`
69
+
70
+
71
+
63
72
  ### Remote Commands
64
73
 
65
74
  For these commands to work you need to have the desired host already added to
@@ -81,8 +90,19 @@ Host *
81
90
 
82
91
  *This wraps mina and deploys using the information contained in cnf.yml*
83
92
 
84
- `bonethug setup {develoment|staging|production}`
85
- `bonethug deploy {develoment|staging|production}`
93
+ `bonethug setup {development|staging|production}`
94
+ `bonethug deploy {develoment|staging|production}`
95
+
96
+
97
+
98
+ **Trigger a Backup from the Remote Server**
99
+
100
+ *This wraps mina and runs the backup task in the bonethug deploy.rb file. Uses
101
+ the info contained in cnf.yml*
102
+
103
+ `bonethug remote-backup {develoment|staging|production}`
104
+
105
+
86
106
 
87
107
 
88
108
  Contributing
data/config/backup.rb CHANGED
@@ -16,7 +16,8 @@ exec_path = File.expand_path(File.dirname(__FILE__))
16
16
  env = ENV['to']
17
17
 
18
18
  # load config
19
- conf = Bonethug::Conf.new.add(exec_path + '/config/cnf.yml').add(exec_path + '/config/database.yml' => { root: 'dbs.default' })
19
+ conf = Bonethug::Conf.new.add(exec_path + '/config/cnf.yml')
20
+ conf.add(exec_path + '/config/database.yml' => { root: 'dbs.default' }) if File.exist? exec_path + '/config/database.yml'
20
21
 
21
22
  # do a check
22
23
  raise 'could not find deployment environment' unless conf.get('deploy.environments').has_key? env
@@ -28,6 +29,8 @@ log_dirs = conf.get('log_dirs','Array')
28
29
  backup = conf.get('backup')
29
30
  backup_slug = deploy.get('project_slug') + "_" + env + "_backup"
30
31
 
32
+ raise "No backup configuraton available" unless backup
33
+
31
34
  # add in any standard folders
32
35
  log_dirs.push('log') unless log_dirs.include? 'log'
33
36
 
@@ -39,7 +42,7 @@ safe do
39
42
 
40
43
  verbose true
41
44
 
42
- local :path => "#{exec_path}/backups/:kind/:id"
45
+ local :path => "#{exec_path}/backups/:kind/:id"
43
46
 
44
47
  # use ftp to back stuff up
45
48
  if backup.get('ftp')
@@ -71,13 +74,14 @@ safe do
71
74
  end
72
75
  end
73
76
 
74
- # how many days are we holding on to backups?
75
- keep do
76
- local backup.get('local.keep')
77
- ftp backup.get('ftp.keep')
78
- sftp backup.get('sftp.keep')
79
- s3 backup.get('s3.keep')
80
- end
77
+ # # how many days are we holding on to backups?
78
+ # keep expects a hash - just don't now why??
79
+ # keep do
80
+ # local backup.get('local.keep')
81
+ # ftp backup.get('ftp.keep') if backup.get('ftp')
82
+ # sftp backup.get('sftp.keep') if backup.get('sftp')
83
+ # s3 backup.get('s3.keep') if backup.get('s3')
84
+ # end
81
85
 
82
86
  # backup mysql databases with mysqldump
83
87
  mysqldump do
data/config/cnf.yml CHANGED
@@ -54,6 +54,10 @@ backup:
54
54
  key: key
55
55
  secret: secret
56
56
  bucket: bucket
57
+ rsync:
58
+ host: backup-host.com
59
+ user: remote_backup
60
+ pass: passw0rd
57
61
  mail:
58
62
  smtp:
59
63
  development:
data/config/deploy.rb CHANGED
@@ -123,9 +123,25 @@ task :backup => :environment do
123
123
  queue! %[cd #{deploy_to}/current && export to=#{env} && bundle exec astrails-safe .bonethug/backup.rb]
124
124
  end
125
125
 
126
- desc "Restores application state to the most recent backup"
127
- task :restore_backup => :environment do
128
- # to be implemented
126
+ desc "Syncs files to a location"
127
+ task :sync_to => :environment do
128
+ if rsync = conf.get('backup.rsync')
129
+ rsync = conf.get('backup.rsync')
130
+ path = deploy.get('project_slug') + "_" + env + "_backup/sync"
131
+ queue! %[cd #{deploy_to}/current && rsync -r -a -v -e "ssh -l #{rsync.user}" --delete . #{rsync.host}:/#{path}/ ]
132
+ else
133
+ raise 'no rsync conf'
134
+ end
135
+ end
136
+
137
+ desc "Restores files from a location"
138
+ task :sync_from => :environment do
139
+ if rsync = conf.get('backup.rsync')
140
+ path = deploy.get('project_slug') + "_" + env + "_backup/sync"
141
+ queue! %[cd #{deploy_to}/current && rsync -r -a -v -e "ssh -l #{rsync.user}" --delete #{rsync.host}:/#{path}/ .]
142
+ else
143
+ raise 'no rsync conf'
144
+ end
129
145
  end
130
146
 
131
147
  desc "Deploys the current version to the server."
data/lib/bonethug/cli.rb CHANGED
@@ -19,7 +19,7 @@ module Bonethug
19
19
  location = ARGV[2] || '.'
20
20
 
21
21
  # validate
22
- if type.empty?
22
+ unless type
23
23
  puts 'Usage: bonethug install [type] [location]'
24
24
  return
25
25
  end
@@ -33,7 +33,7 @@ module Bonethug
33
33
  location = ARGV[1] || '.'
34
34
 
35
35
  # validate
36
- if location.empty?
36
+ unless location
37
37
  puts 'Usage: bonethug #{task} [location]'
38
38
  return
39
39
  end
@@ -41,13 +41,13 @@ module Bonethug
41
41
  # run the initaliser
42
42
  Installer.bonethugise(location, task.to_sym)
43
43
 
44
- when 'deploy', 'setup', 'remote-backup', 'local-backup'
44
+ when 'deploy', 'setup', 'remote-backup', 'local-backup', 'rsync-to-backup', 'rsync-from-backup'
45
45
 
46
46
  # handle args
47
47
  environment = ARGV[1]
48
48
 
49
49
  # validate
50
- if environment.empty?
50
+ unless environment
51
51
  puts 'Usage: bonethug #{task} [environment]'
52
52
  return
53
53
  end
@@ -60,7 +60,7 @@ module Bonethug
60
60
  when 'remote-backup'
61
61
  exec "export to=#{environment} && bundle exec mina -f .bonethug/deploy.rb backup --verbose"
62
62
  when 'local-backup'
63
- exec "export to=#{environment} && bundle exec astrails-safe .bonethug/backup.rb"
63
+ exec "export to=#{environment} && bundle exec astrails-safe .bonethug/backup.rb"
64
64
  end
65
65
 
66
66
  when 'watch'
@@ -235,15 +235,14 @@ module Bonethug
235
235
 
236
236
  add_gem = false;
237
237
  gem_reg = Regexp.new('gem[^"\']+["\']'+gem_name+'["\']')
238
- git_reg = Regexp.new('gem[^"\']+["\']'+gem_name+'["\'],[^,]+github: ["\']'+github+'["\'],') if github
238
+ git_reg = Regexp.new('gem[^"\']+["\']'+gem_name+'["\'],[^,]+github: ["\']'+github+'["\']') if github
239
239
 
240
240
  if gem_reg =~ gemfile_contents
241
- if !github
242
- puts 'Found '+gem_name+' in gem file'
243
- else
241
+ puts 'Found '+gem_name+' in gem file.'
242
+ if github
244
243
  puts 'Requires github version, checking...'
245
244
  unless git_reg =~ gemfile_contents
246
- puts 'Couldn\'t find '+gem_name+' in gem file adding...'
245
+ puts 'Couldn\'t find '+gem_name+' (github) in gem file adding...'
247
246
  gemfile_contents.gsub(gem_reg,'')
248
247
  add_gem = true;
249
248
  end
@@ -1,3 +1,3 @@
1
1
  module Bonethug
2
- VERSION = "0.0.20"
2
+ VERSION = "0.0.21"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bonethug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.21
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: