interu-backup 3.0.16
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/.gitignore +2 -0
- data/Gemfile +31 -0
- data/Gemfile.lock +117 -0
- data/Guardfile +17 -0
- data/LICENSE.md +24 -0
- data/README.md +332 -0
- data/backup.gemspec +31 -0
- data/bin/backup +267 -0
- data/lib/backup.rb +181 -0
- data/lib/backup/archive.rb +73 -0
- data/lib/backup/cli.rb +82 -0
- data/lib/backup/compressor/base.rb +17 -0
- data/lib/backup/compressor/bzip2.rb +64 -0
- data/lib/backup/compressor/gzip.rb +61 -0
- data/lib/backup/configuration/base.rb +15 -0
- data/lib/backup/configuration/compressor/base.rb +10 -0
- data/lib/backup/configuration/compressor/bzip2.rb +23 -0
- data/lib/backup/configuration/compressor/gzip.rb +23 -0
- data/lib/backup/configuration/database/base.rb +18 -0
- data/lib/backup/configuration/database/mongodb.rb +41 -0
- data/lib/backup/configuration/database/mysql.rb +37 -0
- data/lib/backup/configuration/database/postgresql.rb +37 -0
- data/lib/backup/configuration/database/redis.rb +35 -0
- data/lib/backup/configuration/encryptor/base.rb +10 -0
- data/lib/backup/configuration/encryptor/gpg.rb +17 -0
- data/lib/backup/configuration/encryptor/open_ssl.rb +26 -0
- data/lib/backup/configuration/helpers.rb +54 -0
- data/lib/backup/configuration/notifier/base.rb +39 -0
- data/lib/backup/configuration/notifier/campfire.rb +25 -0
- data/lib/backup/configuration/notifier/mail.rb +52 -0
- data/lib/backup/configuration/notifier/presently.rb +25 -0
- data/lib/backup/configuration/notifier/twitter.rb +21 -0
- data/lib/backup/configuration/storage/base.rb +18 -0
- data/lib/backup/configuration/storage/cloudfiles.rb +21 -0
- data/lib/backup/configuration/storage/dropbox.rb +29 -0
- data/lib/backup/configuration/storage/ftp.rb +25 -0
- data/lib/backup/configuration/storage/rsync.rb +25 -0
- data/lib/backup/configuration/storage/s3.rb +25 -0
- data/lib/backup/configuration/storage/scp.rb +25 -0
- data/lib/backup/configuration/storage/sftp.rb +25 -0
- data/lib/backup/configuration/syncer/rsync.rb +45 -0
- data/lib/backup/configuration/syncer/s3.rb +33 -0
- data/lib/backup/database/base.rb +33 -0
- data/lib/backup/database/mongodb.rb +179 -0
- data/lib/backup/database/mysql.rb +104 -0
- data/lib/backup/database/postgresql.rb +111 -0
- data/lib/backup/database/redis.rb +105 -0
- data/lib/backup/dependency.rb +96 -0
- data/lib/backup/encryptor/base.rb +17 -0
- data/lib/backup/encryptor/gpg.rb +78 -0
- data/lib/backup/encryptor/open_ssl.rb +67 -0
- data/lib/backup/exception/command_not_found.rb +8 -0
- data/lib/backup/finder.rb +39 -0
- data/lib/backup/logger.rb +102 -0
- data/lib/backup/model.rb +272 -0
- data/lib/backup/notifier/base.rb +29 -0
- data/lib/backup/notifier/binder.rb +32 -0
- data/lib/backup/notifier/campfire.rb +194 -0
- data/lib/backup/notifier/mail.rb +141 -0
- data/lib/backup/notifier/presently.rb +105 -0
- data/lib/backup/notifier/templates/notify_failure.erb +33 -0
- data/lib/backup/notifier/templates/notify_success.erb +16 -0
- data/lib/backup/notifier/twitter.rb +87 -0
- data/lib/backup/storage/base.rb +67 -0
- data/lib/backup/storage/cloudfiles.rb +95 -0
- data/lib/backup/storage/dropbox.rb +91 -0
- data/lib/backup/storage/ftp.rb +114 -0
- data/lib/backup/storage/object.rb +45 -0
- data/lib/backup/storage/rsync.rb +129 -0
- data/lib/backup/storage/s3.rb +180 -0
- data/lib/backup/storage/scp.rb +106 -0
- data/lib/backup/storage/sftp.rb +106 -0
- data/lib/backup/syncer/base.rb +10 -0
- data/lib/backup/syncer/rsync.rb +152 -0
- data/lib/backup/syncer/s3.rb +118 -0
- data/lib/backup/version.rb +43 -0
- data/lib/templates/archive +7 -0
- data/lib/templates/compressor/bzip2 +7 -0
- data/lib/templates/compressor/gzip +7 -0
- data/lib/templates/database/mongodb +14 -0
- data/lib/templates/database/mysql +14 -0
- data/lib/templates/database/postgresql +14 -0
- data/lib/templates/database/redis +13 -0
- data/lib/templates/encryptor/gpg +12 -0
- data/lib/templates/encryptor/openssl +8 -0
- data/lib/templates/notifier/campfire +11 -0
- data/lib/templates/notifier/mail +17 -0
- data/lib/templates/notifier/presently +12 -0
- data/lib/templates/notifier/twitter +12 -0
- data/lib/templates/readme +15 -0
- data/lib/templates/storage/cloudfiles +10 -0
- data/lib/templates/storage/dropbox +12 -0
- data/lib/templates/storage/ftp +11 -0
- data/lib/templates/storage/rsync +10 -0
- data/lib/templates/storage/s3 +21 -0
- data/lib/templates/storage/scp +11 -0
- data/lib/templates/storage/sftp +11 -0
- data/lib/templates/syncer/rsync +17 -0
- data/lib/templates/syncer/s3 +15 -0
- data/spec/archive_spec.rb +90 -0
- data/spec/backup_spec.rb +11 -0
- data/spec/compressor/bzip2_spec.rb +59 -0
- data/spec/compressor/gzip_spec.rb +59 -0
- data/spec/configuration/base_spec.rb +35 -0
- data/spec/configuration/compressor/gzip_spec.rb +28 -0
- data/spec/configuration/database/base_spec.rb +16 -0
- data/spec/configuration/database/mongodb_spec.rb +30 -0
- data/spec/configuration/database/mysql_spec.rb +32 -0
- data/spec/configuration/database/postgresql_spec.rb +32 -0
- data/spec/configuration/database/redis_spec.rb +30 -0
- data/spec/configuration/encryptor/gpg_spec.rb +25 -0
- data/spec/configuration/encryptor/open_ssl_spec.rb +31 -0
- data/spec/configuration/notifier/campfire_spec.rb +20 -0
- data/spec/configuration/notifier/mail_spec.rb +32 -0
- data/spec/configuration/notifier/twitter_spec.rb +22 -0
- data/spec/configuration/storage/cloudfiles_spec.rb +34 -0
- data/spec/configuration/storage/dropbox_spec.rb +43 -0
- data/spec/configuration/storage/ftp_spec.rb +40 -0
- data/spec/configuration/storage/rsync_spec.rb +37 -0
- data/spec/configuration/storage/s3_spec.rb +37 -0
- data/spec/configuration/storage/scp_spec.rb +40 -0
- data/spec/configuration/storage/sftp_spec.rb +40 -0
- data/spec/configuration/syncer/rsync_spec.rb +46 -0
- data/spec/configuration/syncer/s3_spec.rb +43 -0
- data/spec/database/base_spec.rb +30 -0
- data/spec/database/mongodb_spec.rb +181 -0
- data/spec/database/mysql_spec.rb +150 -0
- data/spec/database/postgresql_spec.rb +164 -0
- data/spec/database/redis_spec.rb +122 -0
- data/spec/encryptor/gpg_spec.rb +57 -0
- data/spec/encryptor/open_ssl_spec.rb +102 -0
- data/spec/logger_spec.rb +58 -0
- data/spec/model_spec.rb +236 -0
- data/spec/notifier/campfire_spec.rb +96 -0
- data/spec/notifier/mail_spec.rb +97 -0
- data/spec/notifier/presently_spec.rb +99 -0
- data/spec/notifier/twitter_spec.rb +86 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/storage/base_spec.rb +33 -0
- data/spec/storage/cloudfiles_spec.rb +102 -0
- data/spec/storage/dropbox_spec.rb +105 -0
- data/spec/storage/ftp_spec.rb +133 -0
- data/spec/storage/object_spec.rb +74 -0
- data/spec/storage/rsync_spec.rb +131 -0
- data/spec/storage/s3_spec.rb +110 -0
- data/spec/storage/scp_spec.rb +129 -0
- data/spec/storage/sftp_spec.rb +125 -0
- data/spec/syncer/rsync_spec.rb +195 -0
- data/spec/syncer/s3_spec.rb +139 -0
- data/spec/version_spec.rb +21 -0
- metadata +231 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# Only load the Net::SFTP library/gem when the Backup::Storage::SFTP class is loaded
|
|
5
|
+
Backup::Dependency.load('net-sftp')
|
|
6
|
+
|
|
7
|
+
module Backup
|
|
8
|
+
module Storage
|
|
9
|
+
class SFTP < Base
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
# Server credentials
|
|
13
|
+
attr_accessor :username, :password
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
# Server IP Address and SFTP port
|
|
17
|
+
attr_accessor :ip, :port
|
|
18
|
+
|
|
19
|
+
##
|
|
20
|
+
# Path to store backups to
|
|
21
|
+
attr_accessor :path
|
|
22
|
+
|
|
23
|
+
##
|
|
24
|
+
# Creates a new instance of the SFTP storage object
|
|
25
|
+
# First it sets the defaults (if any exist) and then evaluates
|
|
26
|
+
# the configuration block which may overwrite these defaults
|
|
27
|
+
def initialize(&block)
|
|
28
|
+
load_defaults!
|
|
29
|
+
|
|
30
|
+
@port ||= 22
|
|
31
|
+
@path ||= 'backups'
|
|
32
|
+
|
|
33
|
+
instance_eval(&block) if block_given?
|
|
34
|
+
|
|
35
|
+
@time = TIME
|
|
36
|
+
@path = path.sub(/^\~\//, '')
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
##
|
|
40
|
+
# This is the remote path to where the backup files will be stored
|
|
41
|
+
def remote_path
|
|
42
|
+
File.join(path, TRIGGER)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
##
|
|
46
|
+
# Performs the backup transfer
|
|
47
|
+
def perform!
|
|
48
|
+
transfer!
|
|
49
|
+
cycle!
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
##
|
|
55
|
+
# Establishes a connection to the remote server and returns the Net::SFTP object.
|
|
56
|
+
# Not doing any instance variable caching because this object gets persisted in YAML
|
|
57
|
+
# format to a file and will issues. This, however has no impact on performance since it only
|
|
58
|
+
# gets invoked once per object for a #transfer! and once for a remove! Backups run in the
|
|
59
|
+
# background anyway so even if it were a bit slower it shouldn't matter.
|
|
60
|
+
def connection
|
|
61
|
+
Net::SFTP.start(ip, username, :password => password, :port => port)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
##
|
|
65
|
+
# Transfers the archived file to the specified remote server
|
|
66
|
+
def transfer!
|
|
67
|
+
Logger.message("#{ self.class } started transferring \"#{ remote_file }\".")
|
|
68
|
+
create_remote_directories!
|
|
69
|
+
connection.upload!(
|
|
70
|
+
File.join(local_path, local_file),
|
|
71
|
+
File.join(remote_path, remote_file)
|
|
72
|
+
)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
##
|
|
76
|
+
# Removes the transferred archive file from the server
|
|
77
|
+
def remove!
|
|
78
|
+
begin
|
|
79
|
+
connection.remove!(
|
|
80
|
+
File.join(remote_path, remote_file)
|
|
81
|
+
)
|
|
82
|
+
rescue Net::SFTP::StatusException
|
|
83
|
+
Logger.warn "Could not remove file \"#{ File.join(remote_path, remote_file) }\"."
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
##
|
|
88
|
+
# Creates (if they don't exist yet) all the directories on the remote
|
|
89
|
+
# server in order to upload the backup file. Net::SFTP does not support
|
|
90
|
+
# paths to directories that don't yet exist when creating new directories.
|
|
91
|
+
# Instead, we split the parts up in to an array (for each '/') and loop through
|
|
92
|
+
# that to create the directories one by one. Net::SFTP raises an exception when
|
|
93
|
+
# the directory it's trying ot create already exists, so we have rescue it
|
|
94
|
+
def create_remote_directories!
|
|
95
|
+
path_parts = Array.new
|
|
96
|
+
remote_path.split('/').each do |path_part|
|
|
97
|
+
path_parts << path_part
|
|
98
|
+
begin
|
|
99
|
+
connection.mkdir!(path_parts.join('/'))
|
|
100
|
+
rescue Net::SFTP::StatusException; end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# Require the tempfile Ruby library when Backup::Syncer::RSync is loaded
|
|
5
|
+
require 'tempfile'
|
|
6
|
+
|
|
7
|
+
module Backup
|
|
8
|
+
module Syncer
|
|
9
|
+
class RSync < Base
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
# Server credentials
|
|
13
|
+
attr_accessor :username, :password
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
# Server IP Address and SSH port
|
|
17
|
+
attr_accessor :ip
|
|
18
|
+
|
|
19
|
+
##
|
|
20
|
+
# The SSH port to connect to
|
|
21
|
+
attr_writer :port
|
|
22
|
+
|
|
23
|
+
##
|
|
24
|
+
# Directories to sync
|
|
25
|
+
attr_writer :directories
|
|
26
|
+
|
|
27
|
+
##
|
|
28
|
+
# Path to store the synced files/directories to
|
|
29
|
+
attr_accessor :path
|
|
30
|
+
|
|
31
|
+
##
|
|
32
|
+
# Flag for mirroring the files/directories
|
|
33
|
+
attr_writer :mirror
|
|
34
|
+
|
|
35
|
+
##
|
|
36
|
+
# Flag for compressing (only compresses for the transfer)
|
|
37
|
+
attr_writer :compress
|
|
38
|
+
|
|
39
|
+
##
|
|
40
|
+
# Additional options for the rsync cli
|
|
41
|
+
attr_accessor :additional_options
|
|
42
|
+
|
|
43
|
+
##
|
|
44
|
+
# Instantiates a new RSync Syncer object and sets the default configuration
|
|
45
|
+
# specified in the Backup::Configuration::Syncer::RSync. Then it sets the object
|
|
46
|
+
# defaults if particular properties weren't set. Finally it'll evaluate the users
|
|
47
|
+
# configuration file and overwrite anything that's been defined
|
|
48
|
+
def initialize(&block)
|
|
49
|
+
load_defaults!
|
|
50
|
+
|
|
51
|
+
@directories = Array.new
|
|
52
|
+
@additional_options ||= Array.new
|
|
53
|
+
@path ||= 'backups'
|
|
54
|
+
@port ||= 22
|
|
55
|
+
@mirror ||= false
|
|
56
|
+
@compress ||= false
|
|
57
|
+
|
|
58
|
+
instance_eval(&block) if block_given?
|
|
59
|
+
write_password_file!
|
|
60
|
+
|
|
61
|
+
@path = path.sub(/^\~\//, '')
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
##
|
|
65
|
+
# Performs the RSync operation
|
|
66
|
+
# debug options: -vhP
|
|
67
|
+
def perform!
|
|
68
|
+
Logger.message("#{ self.class } started syncing #{ directories }.")
|
|
69
|
+
Logger.silent(
|
|
70
|
+
run("#{ utility(:rsync) } -vhP #{ options } #{ directories } '#{ username }@#{ ip }:#{ path }'")
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
remove_password_file!
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
##
|
|
77
|
+
# Returns all the specified Rsync options, concatenated, ready for the CLI
|
|
78
|
+
def options
|
|
79
|
+
([archive, mirror, compress, port, password] + additional_options).compact.join("\s")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
##
|
|
83
|
+
# Returns Rsync syntax for enabling mirroring
|
|
84
|
+
def mirror
|
|
85
|
+
'--delete' if @mirror
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
##
|
|
89
|
+
# Returns Rsync syntax for compressing the file transfers
|
|
90
|
+
def compress
|
|
91
|
+
'--compress' if @compress
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
##
|
|
95
|
+
# Returns Rsync syntax for invoking "archive" mode
|
|
96
|
+
def archive
|
|
97
|
+
'--archive'
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
##
|
|
101
|
+
# Returns Rsync syntax for defining a port to connect to
|
|
102
|
+
def port
|
|
103
|
+
"--port='#{@port}'"
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
##
|
|
107
|
+
# Returns Rsync syntax for setting a password (via a file)
|
|
108
|
+
def password
|
|
109
|
+
"--password-file='#{@password_file.path}'" unless @password.nil?
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
##
|
|
113
|
+
# If no block has been provided, it'll return the array of @directories.
|
|
114
|
+
# If a block has been provided, it'll evaluate it and add the defined paths to the @directories
|
|
115
|
+
def directories(&block)
|
|
116
|
+
unless block_given?
|
|
117
|
+
return @directories.map do |directory|
|
|
118
|
+
"'#{directory}'"
|
|
119
|
+
end.join("\s")
|
|
120
|
+
end
|
|
121
|
+
instance_eval(&block)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
##
|
|
125
|
+
# Adds a path to the @directories array
|
|
126
|
+
def add(path)
|
|
127
|
+
@directories << path
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
private
|
|
131
|
+
|
|
132
|
+
##
|
|
133
|
+
# Writes the provided password to a temporary file so that
|
|
134
|
+
# the rsync utility can read the password from this file
|
|
135
|
+
def write_password_file!
|
|
136
|
+
unless @password.nil?
|
|
137
|
+
@password_file = Tempfile.new('backup-rsync-password')
|
|
138
|
+
@password_file.write(@password)
|
|
139
|
+
@password_file.close
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
##
|
|
144
|
+
# Removes the previously created @password_file
|
|
145
|
+
# (temporary file containing the password)
|
|
146
|
+
def remove_password_file!
|
|
147
|
+
@password_file.unlink unless @password.nil?
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
module Backup
|
|
4
|
+
module Syncer
|
|
5
|
+
class S3 < Base
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Amazon Simple Storage Service (S3) Credentials
|
|
9
|
+
attr_accessor :access_key_id, :secret_access_key
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
# Amazon S3 bucket name and path to sync to
|
|
13
|
+
attr_accessor :bucket, :path
|
|
14
|
+
|
|
15
|
+
##
|
|
16
|
+
# Directories to sync
|
|
17
|
+
attr_accessor :directories
|
|
18
|
+
|
|
19
|
+
##
|
|
20
|
+
# Flag to enable mirroring
|
|
21
|
+
attr_accessor :mirror
|
|
22
|
+
|
|
23
|
+
##
|
|
24
|
+
# Additional options for the s3sync cli
|
|
25
|
+
attr_accessor :additional_options
|
|
26
|
+
|
|
27
|
+
##
|
|
28
|
+
# Instantiates a new S3 Syncer object and sets the default configuration
|
|
29
|
+
# specified in the Backup::Configuration::Syncer::S3. Then it sets the object
|
|
30
|
+
# defaults if particular properties weren't set. Finally it'll evaluate the users
|
|
31
|
+
# configuration file and overwrite anything that's been defined
|
|
32
|
+
def initialize(&block)
|
|
33
|
+
load_defaults!
|
|
34
|
+
|
|
35
|
+
@path ||= 'backups'
|
|
36
|
+
@directories ||= Array.new
|
|
37
|
+
@mirror ||= false
|
|
38
|
+
@additional_options ||= []
|
|
39
|
+
|
|
40
|
+
instance_eval(&block) if block_given?
|
|
41
|
+
|
|
42
|
+
@path = path.sub(/^\//, '')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
##
|
|
46
|
+
# Performs the S3Sync operation
|
|
47
|
+
# First it'll set the Amazon S3 credentials for S3Sync before invoking it,
|
|
48
|
+
# and once it's finished syncing the files and directories to Amazon S3, it'll
|
|
49
|
+
# unset these credentials (back to nil values)
|
|
50
|
+
def perform!
|
|
51
|
+
set_environment_variables!
|
|
52
|
+
|
|
53
|
+
directories.each do |directory|
|
|
54
|
+
Logger.message("#{ self.class } started syncing '#{ directory }'.")
|
|
55
|
+
Logger.silent( run("#{ utility(:s3sync) } #{ options } '#{ directory }' '#{ bucket }:#{ path }'") )
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
unset_environment_variables!
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
##
|
|
62
|
+
# Returns all the specified S3Sync options, concatenated, ready for the CLI
|
|
63
|
+
def options
|
|
64
|
+
([verbose, recursive, mirror] + additional_options).compact.join("\s")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
##
|
|
68
|
+
# Returns S3Sync syntax for enabling mirroring
|
|
69
|
+
def mirror
|
|
70
|
+
'--delete' if @mirror
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
##
|
|
74
|
+
# Returns S3Sync syntax for syncing recursively
|
|
75
|
+
def recursive
|
|
76
|
+
'--recursive'
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
##
|
|
80
|
+
# Returns S3Sync syntax for making output verbose
|
|
81
|
+
def verbose
|
|
82
|
+
'--verbose'
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
##
|
|
86
|
+
# Syntactical suger for the DSL for adding directories
|
|
87
|
+
def directories(&block)
|
|
88
|
+
return @directories unless block_given?
|
|
89
|
+
instance_eval(&block)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
##
|
|
93
|
+
# Adds a path to the @directories array
|
|
94
|
+
def add(path)
|
|
95
|
+
@directories << path
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
##
|
|
99
|
+
# In order for S3Sync to know what credentials to use, we have to set the
|
|
100
|
+
# AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables, these
|
|
101
|
+
# evironment variables will be used by S3Sync
|
|
102
|
+
def set_environment_variables!
|
|
103
|
+
ENV['AWS_ACCESS_KEY_ID'] = access_key_id
|
|
104
|
+
ENV['AWS_SECRET_ACCESS_KEY'] = secret_access_key
|
|
105
|
+
ENV['AWS_CALLING_FORMAT'] = 'SUBDOMAIN'
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
##
|
|
109
|
+
# Sets the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY back to nil
|
|
110
|
+
def unset_environment_variables!
|
|
111
|
+
ENV['AWS_ACCESS_KEY_ID'] = nil
|
|
112
|
+
ENV['AWS_SECRET_ACCESS_KEY'] = nil
|
|
113
|
+
ENV['AWS_CALLING_FORMAT'] = nil
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
module Backup
|
|
4
|
+
class Version
|
|
5
|
+
|
|
6
|
+
##
|
|
7
|
+
# Change the MAJOR, MINOR and PATCH constants below
|
|
8
|
+
# to adjust the version of the Backup gem
|
|
9
|
+
#
|
|
10
|
+
# MAJOR:
|
|
11
|
+
# Defines the major version
|
|
12
|
+
# MINOR:
|
|
13
|
+
# Defines the minor version
|
|
14
|
+
# PATCH:
|
|
15
|
+
# Defines the patch version
|
|
16
|
+
MAJOR, MINOR, PATCH = 3, 0, 16
|
|
17
|
+
|
|
18
|
+
##
|
|
19
|
+
# Returns the major version ( big release based off of multiple minor releases )
|
|
20
|
+
def self.major
|
|
21
|
+
MAJOR
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
##
|
|
25
|
+
# Returns the minor version ( small release based off of multiple patches )
|
|
26
|
+
def self.minor
|
|
27
|
+
MINOR
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
##
|
|
31
|
+
# Returns the patch version ( updates, features and (crucial) bug fixes )
|
|
32
|
+
def self.patch
|
|
33
|
+
PATCH
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
##
|
|
37
|
+
# Returns the current version of the Backup gem ( qualified for the gemspec )
|
|
38
|
+
def self.current
|
|
39
|
+
"#{major}.#{minor}.#{patch}"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
end
|