backup 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -75,9 +75,9 @@ http://wiki.github.com/meskyanichi/backup/installation
75
75
  http://wiki.github.com/meskyanichi/backup/getting-started
76
76
 
77
77
 
78
- === Requirements
78
+ === Rake Tasks
79
79
 
80
- http://wiki.github.com/meskyanichi/backup/requirements
80
+ http://wiki.github.com/meskyanichi/backup/rake-tasks
81
81
 
82
82
 
83
83
  === Automatic Backups
@@ -90,6 +90,26 @@ http://wiki.github.com/meskyanichi/backup/automatic-backups
90
90
  http://wiki.github.com/meskyanichi/backup/capistrano-recipes
91
91
 
92
92
 
93
+ === Capistrano, Whenever!
94
+
95
+ http://wiki.github.com/meskyanichi/backup/capistrano-whenever
96
+
97
+
98
+ === Understanding "The Backup Database"
99
+
100
+ http://wiki.github.com/meskyanichi/backup/the-backup-database
101
+
102
+
103
+ === Trouble Shooting
104
+
105
+ http://wiki.github.com/meskyanichi/backup/troubleshooting
106
+
107
+
108
+ === Requirements
109
+
110
+ http://wiki.github.com/meskyanichi/backup/requirements
111
+
112
+
93
113
  === Resources
94
114
 
95
115
  http://wiki.github.com/meskyanichi/backup/resources
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.2
1
+ 1.3.0
data/backup.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{backup}
8
- s.version = "1.2.2"
8
+ s.version = "1.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["meskyanichi"]
@@ -25,17 +25,17 @@ namespace :backup do
25
25
  @adapters.each do |adapter|
26
26
  if @config[adapter]
27
27
  unless @config[adapter].is_a?(Array)
28
- puts "\n\n-- Processing #{adapter} backups.. --"
28
+ puts "\n\n-- Processing #{adapter} backups --"
29
29
  Backup::BackupRecord::S3.destroy_all_backups(adapter, @config[adapter], 0)
30
30
  else
31
- puts "\n\n-- Processing #{adapter} backups.. --"
31
+ puts "\n\n-- Processing #{adapter} backups --"
32
32
  @config[adapter].each_with_index do |config, index|
33
33
  Backup::BackupRecord::S3.destroy_all_backups(adapter, config, index)
34
34
  end
35
35
  end
36
36
  end
37
37
  end
38
- puts "\n\nAll S3 backups destroyed!"
38
+ puts "\n\nAll S3 backups destroyed!\n\n"
39
39
  end
40
40
 
41
41
  desc 'Destroys SSH Backup database records; Physical files WILL be deleted as well.'
@@ -44,17 +44,17 @@ namespace :backup do
44
44
  @adapters.each do |adapter|
45
45
  if @config[adapter]
46
46
  unless @config[adapter].is_a?(Array)
47
- puts "\n\n-- Processing #{adapter} backups.. --"
47
+ puts "\n\n-- Processing #{adapter} backups --"
48
48
  Backup::BackupRecord::SSH.destroy_all_backups(adapter, @config[adapter], 0)
49
49
  else
50
- puts "\n\n-- Processing #{adapter} backups.. --"
50
+ puts "\n\n-- Processing #{adapter} backups --"
51
51
  @config[adapter].each_with_index do |config, index|
52
52
  Backup::BackupRecord::SSH.destroy_all_backups(adapter, config, index)
53
53
  end
54
54
  end
55
55
  end
56
56
  end
57
- puts "All backups from remote server destroyed!"
57
+ puts "\n\nAll backups from remote server destroyed!\n\n"
58
58
  end
59
59
 
60
60
  end
@@ -33,14 +33,23 @@ module Backup
33
33
  self.index = options[:index]
34
34
  end
35
35
 
36
+ # This will only be triggered by the rake task
37
+ # rake backup:db:destroy:s3
38
+ #
39
+ # This will loop through all the configured adapters
40
+ # and destroy all "Backup" database records for the
41
+ # S3 table and delete all backed up files from the
42
+ # Amazon S3 server.
36
43
  def self.destroy_all_backups(adapter, options, index)
37
- s3 = Backup::Connection::S3.new(options)
38
- s3.connect
39
44
  backups = Backup::BackupRecord::S3.all(:conditions => {:adapter => adapter, :index => index})
40
- backups.each do |backup|
41
- puts "Destroying backup: #{backup.backup_file}.."
42
- s3.destroy(backup.backup_file, backup.bucket)
43
- backup.destroy
45
+ unless backups.empty?
46
+ s3 = Backup::Connection::S3.new(options)
47
+ s3.connect
48
+ backups.each do |backup|
49
+ puts "Destroying backup: #{backup.backup_file}.."
50
+ s3.destroy(backup.backup_file, backup.bucket)
51
+ backup.destroy
52
+ end
44
53
  end
45
54
  end
46
55
 
@@ -34,15 +34,24 @@ module Backup
34
34
  self.ip = options[:ssh][:ip]
35
35
  self.user = options[:ssh][:user]
36
36
  end
37
-
37
+
38
+ # This will only be triggered by the rake task
39
+ # rake backup:db:destroy:ssh
40
+ #
41
+ # This will loop through all the configured adapters
42
+ # and destroy all "Backup" database records for the
43
+ # SSH table and delete all backed up files from the
44
+ # remote server on which they are stored.
38
45
  def self.destroy_all_backups(adapter, options, index)
39
46
  backups = Backup::BackupRecord::SSH.all(:conditions => {:adapter => adapter, :index => index})
40
- Net::SSH.start(options['ssh']['ip'], options['ssh']['user']) do |ssh|
41
- # Loop through all backups that should be destroyed and remove them from remote server.
42
- backups.each do |backup|
43
- puts "Destroying old backup: #{backup.backup_file}.."
44
- ssh.exec("rm #{File.join(backup.backup_path, backup.backup_file)}")
45
- backup.destroy
47
+ unless backups.empty?
48
+ Net::SSH.start(options['ssh']['ip'], options['ssh']['user']) do |ssh|
49
+ # Loop through all backups that should be destroyed and remove them from remote server.
50
+ backups.each do |backup|
51
+ puts "Destroying old backup: #{backup.backup_file}.."
52
+ ssh.exec("rm #{File.join(backup.backup_path, backup.backup_file)}")
53
+ backup.destroy
54
+ end
46
55
  end
47
56
  end
48
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - meskyanichi