backup 1.2.2 → 1.3.0
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.rdoc +22 -2
- data/VERSION +1 -1
- data/backup.gemspec +1 -1
- data/generators/backup_files/templates/db.rake +6 -6
- data/lib/backup/backup_record/s3.rb +15 -6
- data/lib/backup/backup_record/ssh.rb +16 -7
- metadata +1 -1
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
|
-
===
|
78
|
+
=== Rake Tasks
|
79
79
|
|
80
|
-
http://wiki.github.com/meskyanichi/backup/
|
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.
|
1
|
+
1.3.0
|
data/backup.gemspec
CHANGED
@@ -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 "
|
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.
|
41
|
-
|
42
|
-
s3.
|
43
|
-
backup
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|