liquid_backup 0.1.0 → 0.1.1
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/VERSION +1 -1
- data/lib/{backup → liquid_backup}/handler/s3.rb +1 -1
- data/lib/{backup → liquid_backup}/job.rb +3 -3
- data/lib/{backup → liquid_backup}/manager.rb +2 -2
- data/lib/liquid_backup.rb +15 -0
- data/spec/backup_spec.rb +10 -10
- data/spec/spec_helper.rb +1 -1
- metadata +6 -6
- data/lib/backup.rb +0 -15
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class LiquidBackup::Job
|
2
2
|
attr_accessor :script_path
|
3
3
|
attr_accessor :application_directory
|
4
4
|
attr_accessor :backups_path
|
@@ -55,7 +55,7 @@ class Backup::Job
|
|
55
55
|
|
56
56
|
previous_backups = Dir.glob(File.join(previous_backups_path,'*')).sort
|
57
57
|
|
58
|
-
backups_to_prune = previous_backups - previous_backups[-
|
58
|
+
backups_to_prune = previous_backups - previous_backups[-LiquidBackup::KEEP,LiquidBackup::KEEP]
|
59
59
|
|
60
60
|
FileUtils.rm_rf backups_to_prune
|
61
61
|
end
|
@@ -76,7 +76,7 @@ class Backup::Job
|
|
76
76
|
|
77
77
|
def upload
|
78
78
|
files_to_backup = Dir.glob(File.join(current_backup_path,'*.tar.gz'))
|
79
|
-
|
79
|
+
LiquidBackup::Manager.handler(destination_handler).store(destination_location, files_to_backup)
|
80
80
|
end
|
81
81
|
|
82
82
|
def compress(source,destination)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
class
|
2
|
+
class LiquidBackup::Manager
|
3
3
|
include Singleton
|
4
4
|
|
5
5
|
attr_accessor :backup_handler
|
@@ -11,7 +11,7 @@ class Backup::Manager
|
|
11
11
|
def collect_jobs(pattern)
|
12
12
|
@backup_jobs = []
|
13
13
|
Dir.glob(pattern).each do |backupjob|
|
14
|
-
@backup_jobs <<
|
14
|
+
@backup_jobs << LiquidBackup::Job.new(backupjob)
|
15
15
|
end
|
16
16
|
@backup_jobs
|
17
17
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'singleton'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
module LiquidBackup
|
6
|
+
KEEP = 7
|
7
|
+
end
|
8
|
+
|
9
|
+
$: << File.join(File.dirname(__FILE__),'liquid_backup')
|
10
|
+
|
11
|
+
require 'job'
|
12
|
+
require 'manager'
|
13
|
+
|
14
|
+
|
15
|
+
Dir.glob(File.join(File.dirname(__FILE__),'liquid_backup','handler','*.rb')).each{|h| require h}
|
data/spec/backup_spec.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe LiquidBackup do
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe LiquidBackup::Manager do
|
6
6
|
it "should return a list of backup jobs" do
|
7
|
-
jobs =
|
7
|
+
jobs = LiquidBackup::Manager.collect_jobs(File.join(File.dirname(__FILE__),'fs_root/home/**/current/config/backup.rb'))
|
8
8
|
jobs.should be_an(Array)
|
9
9
|
|
10
|
-
jobs.first.should be_an(
|
10
|
+
jobs.first.should be_an(LiquidBackup::Job)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
describe
|
14
|
+
describe LiquidBackup::Job do
|
15
15
|
before(:each) do
|
16
|
-
@job =
|
16
|
+
@job = LiquidBackup::Job.new(File.join(File.dirname(__FILE__), "/fs_root/home/user1/app1/production/current/config/backup.rb"))
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should report the correct application directory" do
|
@@ -29,11 +29,11 @@ describe Backup do
|
|
29
29
|
credidentials = {:access_key_id =>'acces_key', :secret_access_key =>"secret"}
|
30
30
|
AWS::S3::Base.should_receive(:establish_connection!).with(credidentials).and_return(true)
|
31
31
|
|
32
|
-
s3 =
|
33
|
-
|
32
|
+
s3 = LiquidBackup::Handler::S3.new(credidentials)
|
33
|
+
LiquidBackup::Manager.use(:s3, s3)
|
34
34
|
|
35
|
-
@job =
|
36
|
-
|
35
|
+
@job = LiquidBackup::Job.new(File.join(File.dirname(__FILE__), "/fs_root/home/user1/app1/production/current/config/backup.rb"))
|
36
|
+
LiquidBackup::Manager.handler(:s3).should_receive(:store).with('liquidmedia_fairness',Dir.glob(File.join(@job.current_backup_path,'*.tar.gz'))).and_return(true)
|
37
37
|
@job.perform
|
38
38
|
end
|
39
39
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Dan Williams
|
@@ -59,10 +59,10 @@ files:
|
|
59
59
|
- README.md
|
60
60
|
- Rakefile
|
61
61
|
- VERSION
|
62
|
-
- lib/
|
63
|
-
- lib/
|
64
|
-
- lib/
|
65
|
-
- lib/
|
62
|
+
- lib/liquid_backup.rb
|
63
|
+
- lib/liquid_backup/handler/s3.rb
|
64
|
+
- lib/liquid_backup/job.rb
|
65
|
+
- lib/liquid_backup/manager.rb
|
66
66
|
- spec/backup_spec.rb
|
67
67
|
- spec/fs_root/home/user1/app1/production/current/public/system/important_files/file1.txt
|
68
68
|
- spec/fs_root/home/user1/app1/production/current/public/system/important_files/file2.txt
|
data/lib/backup.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'singleton'
|
3
|
-
require 'date'
|
4
|
-
|
5
|
-
module Backup
|
6
|
-
KEEP = 7
|
7
|
-
end
|
8
|
-
|
9
|
-
$: << File.join(File.dirname(__FILE__),'backup')
|
10
|
-
|
11
|
-
require 'job'
|
12
|
-
require 'manager'
|
13
|
-
|
14
|
-
|
15
|
-
Dir.glob(File.join(File.dirname(__FILE__),'backup','handler','*.rb')).each{|h| require h}
|