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.
Files changed (151) hide show
  1. data/.gitignore +2 -0
  2. data/Gemfile +31 -0
  3. data/Gemfile.lock +117 -0
  4. data/Guardfile +17 -0
  5. data/LICENSE.md +24 -0
  6. data/README.md +332 -0
  7. data/backup.gemspec +31 -0
  8. data/bin/backup +267 -0
  9. data/lib/backup.rb +181 -0
  10. data/lib/backup/archive.rb +73 -0
  11. data/lib/backup/cli.rb +82 -0
  12. data/lib/backup/compressor/base.rb +17 -0
  13. data/lib/backup/compressor/bzip2.rb +64 -0
  14. data/lib/backup/compressor/gzip.rb +61 -0
  15. data/lib/backup/configuration/base.rb +15 -0
  16. data/lib/backup/configuration/compressor/base.rb +10 -0
  17. data/lib/backup/configuration/compressor/bzip2.rb +23 -0
  18. data/lib/backup/configuration/compressor/gzip.rb +23 -0
  19. data/lib/backup/configuration/database/base.rb +18 -0
  20. data/lib/backup/configuration/database/mongodb.rb +41 -0
  21. data/lib/backup/configuration/database/mysql.rb +37 -0
  22. data/lib/backup/configuration/database/postgresql.rb +37 -0
  23. data/lib/backup/configuration/database/redis.rb +35 -0
  24. data/lib/backup/configuration/encryptor/base.rb +10 -0
  25. data/lib/backup/configuration/encryptor/gpg.rb +17 -0
  26. data/lib/backup/configuration/encryptor/open_ssl.rb +26 -0
  27. data/lib/backup/configuration/helpers.rb +54 -0
  28. data/lib/backup/configuration/notifier/base.rb +39 -0
  29. data/lib/backup/configuration/notifier/campfire.rb +25 -0
  30. data/lib/backup/configuration/notifier/mail.rb +52 -0
  31. data/lib/backup/configuration/notifier/presently.rb +25 -0
  32. data/lib/backup/configuration/notifier/twitter.rb +21 -0
  33. data/lib/backup/configuration/storage/base.rb +18 -0
  34. data/lib/backup/configuration/storage/cloudfiles.rb +21 -0
  35. data/lib/backup/configuration/storage/dropbox.rb +29 -0
  36. data/lib/backup/configuration/storage/ftp.rb +25 -0
  37. data/lib/backup/configuration/storage/rsync.rb +25 -0
  38. data/lib/backup/configuration/storage/s3.rb +25 -0
  39. data/lib/backup/configuration/storage/scp.rb +25 -0
  40. data/lib/backup/configuration/storage/sftp.rb +25 -0
  41. data/lib/backup/configuration/syncer/rsync.rb +45 -0
  42. data/lib/backup/configuration/syncer/s3.rb +33 -0
  43. data/lib/backup/database/base.rb +33 -0
  44. data/lib/backup/database/mongodb.rb +179 -0
  45. data/lib/backup/database/mysql.rb +104 -0
  46. data/lib/backup/database/postgresql.rb +111 -0
  47. data/lib/backup/database/redis.rb +105 -0
  48. data/lib/backup/dependency.rb +96 -0
  49. data/lib/backup/encryptor/base.rb +17 -0
  50. data/lib/backup/encryptor/gpg.rb +78 -0
  51. data/lib/backup/encryptor/open_ssl.rb +67 -0
  52. data/lib/backup/exception/command_not_found.rb +8 -0
  53. data/lib/backup/finder.rb +39 -0
  54. data/lib/backup/logger.rb +102 -0
  55. data/lib/backup/model.rb +272 -0
  56. data/lib/backup/notifier/base.rb +29 -0
  57. data/lib/backup/notifier/binder.rb +32 -0
  58. data/lib/backup/notifier/campfire.rb +194 -0
  59. data/lib/backup/notifier/mail.rb +141 -0
  60. data/lib/backup/notifier/presently.rb +105 -0
  61. data/lib/backup/notifier/templates/notify_failure.erb +33 -0
  62. data/lib/backup/notifier/templates/notify_success.erb +16 -0
  63. data/lib/backup/notifier/twitter.rb +87 -0
  64. data/lib/backup/storage/base.rb +67 -0
  65. data/lib/backup/storage/cloudfiles.rb +95 -0
  66. data/lib/backup/storage/dropbox.rb +91 -0
  67. data/lib/backup/storage/ftp.rb +114 -0
  68. data/lib/backup/storage/object.rb +45 -0
  69. data/lib/backup/storage/rsync.rb +129 -0
  70. data/lib/backup/storage/s3.rb +180 -0
  71. data/lib/backup/storage/scp.rb +106 -0
  72. data/lib/backup/storage/sftp.rb +106 -0
  73. data/lib/backup/syncer/base.rb +10 -0
  74. data/lib/backup/syncer/rsync.rb +152 -0
  75. data/lib/backup/syncer/s3.rb +118 -0
  76. data/lib/backup/version.rb +43 -0
  77. data/lib/templates/archive +7 -0
  78. data/lib/templates/compressor/bzip2 +7 -0
  79. data/lib/templates/compressor/gzip +7 -0
  80. data/lib/templates/database/mongodb +14 -0
  81. data/lib/templates/database/mysql +14 -0
  82. data/lib/templates/database/postgresql +14 -0
  83. data/lib/templates/database/redis +13 -0
  84. data/lib/templates/encryptor/gpg +12 -0
  85. data/lib/templates/encryptor/openssl +8 -0
  86. data/lib/templates/notifier/campfire +11 -0
  87. data/lib/templates/notifier/mail +17 -0
  88. data/lib/templates/notifier/presently +12 -0
  89. data/lib/templates/notifier/twitter +12 -0
  90. data/lib/templates/readme +15 -0
  91. data/lib/templates/storage/cloudfiles +10 -0
  92. data/lib/templates/storage/dropbox +12 -0
  93. data/lib/templates/storage/ftp +11 -0
  94. data/lib/templates/storage/rsync +10 -0
  95. data/lib/templates/storage/s3 +21 -0
  96. data/lib/templates/storage/scp +11 -0
  97. data/lib/templates/storage/sftp +11 -0
  98. data/lib/templates/syncer/rsync +17 -0
  99. data/lib/templates/syncer/s3 +15 -0
  100. data/spec/archive_spec.rb +90 -0
  101. data/spec/backup_spec.rb +11 -0
  102. data/spec/compressor/bzip2_spec.rb +59 -0
  103. data/spec/compressor/gzip_spec.rb +59 -0
  104. data/spec/configuration/base_spec.rb +35 -0
  105. data/spec/configuration/compressor/gzip_spec.rb +28 -0
  106. data/spec/configuration/database/base_spec.rb +16 -0
  107. data/spec/configuration/database/mongodb_spec.rb +30 -0
  108. data/spec/configuration/database/mysql_spec.rb +32 -0
  109. data/spec/configuration/database/postgresql_spec.rb +32 -0
  110. data/spec/configuration/database/redis_spec.rb +30 -0
  111. data/spec/configuration/encryptor/gpg_spec.rb +25 -0
  112. data/spec/configuration/encryptor/open_ssl_spec.rb +31 -0
  113. data/spec/configuration/notifier/campfire_spec.rb +20 -0
  114. data/spec/configuration/notifier/mail_spec.rb +32 -0
  115. data/spec/configuration/notifier/twitter_spec.rb +22 -0
  116. data/spec/configuration/storage/cloudfiles_spec.rb +34 -0
  117. data/spec/configuration/storage/dropbox_spec.rb +43 -0
  118. data/spec/configuration/storage/ftp_spec.rb +40 -0
  119. data/spec/configuration/storage/rsync_spec.rb +37 -0
  120. data/spec/configuration/storage/s3_spec.rb +37 -0
  121. data/spec/configuration/storage/scp_spec.rb +40 -0
  122. data/spec/configuration/storage/sftp_spec.rb +40 -0
  123. data/spec/configuration/syncer/rsync_spec.rb +46 -0
  124. data/spec/configuration/syncer/s3_spec.rb +43 -0
  125. data/spec/database/base_spec.rb +30 -0
  126. data/spec/database/mongodb_spec.rb +181 -0
  127. data/spec/database/mysql_spec.rb +150 -0
  128. data/spec/database/postgresql_spec.rb +164 -0
  129. data/spec/database/redis_spec.rb +122 -0
  130. data/spec/encryptor/gpg_spec.rb +57 -0
  131. data/spec/encryptor/open_ssl_spec.rb +102 -0
  132. data/spec/logger_spec.rb +58 -0
  133. data/spec/model_spec.rb +236 -0
  134. data/spec/notifier/campfire_spec.rb +96 -0
  135. data/spec/notifier/mail_spec.rb +97 -0
  136. data/spec/notifier/presently_spec.rb +99 -0
  137. data/spec/notifier/twitter_spec.rb +86 -0
  138. data/spec/spec_helper.rb +25 -0
  139. data/spec/storage/base_spec.rb +33 -0
  140. data/spec/storage/cloudfiles_spec.rb +102 -0
  141. data/spec/storage/dropbox_spec.rb +105 -0
  142. data/spec/storage/ftp_spec.rb +133 -0
  143. data/spec/storage/object_spec.rb +74 -0
  144. data/spec/storage/rsync_spec.rb +131 -0
  145. data/spec/storage/s3_spec.rb +110 -0
  146. data/spec/storage/scp_spec.rb +129 -0
  147. data/spec/storage/sftp_spec.rb +125 -0
  148. data/spec/syncer/rsync_spec.rb +195 -0
  149. data/spec/syncer/s3_spec.rb +139 -0
  150. data/spec/version_spec.rb +21 -0
  151. metadata +231 -0
@@ -0,0 +1,37 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Configuration
5
+ module Database
6
+ class PostgreSQL < Base
7
+ class << self
8
+
9
+ ##
10
+ # Name of the database that needs to get dumped
11
+ attr_accessor :name
12
+
13
+ ##
14
+ # Credentials for the specified database
15
+ attr_accessor :username, :password
16
+
17
+ ##
18
+ # Connectivity options
19
+ attr_accessor :host, :port, :socket
20
+
21
+ ##
22
+ # Tables to skip while dumping the database
23
+ attr_accessor :skip_tables
24
+
25
+ ##
26
+ # Tables to dump, tables that aren't specified won't get dumped
27
+ attr_accessor :only_tables
28
+
29
+ ##
30
+ # Additional "pg_dump" options
31
+ attr_accessor :additional_options
32
+
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Configuration
5
+ module Database
6
+ class Redis < Base
7
+ class << self
8
+
9
+ ##
10
+ # Name of and path to the database that needs to get dumped
11
+ attr_accessor :name, :path
12
+
13
+ ##
14
+ # Credentials for the specified database
15
+ attr_accessor :password
16
+
17
+ ##
18
+ # Determines whether Backup should invoke the SAVE command through
19
+ # the 'redis-cli' utility to persist the most recent data before
20
+ # copying over the dump file
21
+ attr_accessor :invoke_save
22
+
23
+ ##
24
+ # Connectivity options
25
+ attr_accessor :host, :port, :socket
26
+
27
+ ##
28
+ # Additional "redis-cli" options
29
+ attr_accessor :additional_options
30
+
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Configuration
5
+ module Encryptor
6
+ class Base < Backup::Configuration::Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Configuration
5
+ module Encryptor
6
+ class GPG < Base
7
+ class << self
8
+
9
+ ##
10
+ # The GPG Public key that'll be used to encrypt the backup
11
+ attr_accessor :key
12
+
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Configuration
5
+ module Encryptor
6
+ class OpenSSL < Base
7
+ class << self
8
+
9
+ ##
10
+ # The password that'll be used to encrypt the backup. This
11
+ # password will be required to decrypt the backup later on.
12
+ attr_accessor :password
13
+
14
+ ##
15
+ # Determines whether the 'base64' should be used or not
16
+ attr_accessor :base64
17
+
18
+ ##
19
+ # Determines whether the 'salt' flag should be used
20
+ attr_accessor :salt
21
+
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Configuration
5
+ module Helpers
6
+
7
+ ##
8
+ # Finds all the object's getter methods and checks the global
9
+ # configuration for these methods, if they respond then they will
10
+ # assign the object's attribute(s) to that particular global configuration's attribute
11
+ def load_defaults!
12
+ c = self.class.name.split('::')
13
+ configuration = Backup::Configuration.const_get(c[1]).const_get(c[2])
14
+
15
+ getter_methods.each do |attribute|
16
+ if configuration.respond_to?(attribute)
17
+ unless configuration.send(attribute).nil?
18
+ self.send("#{attribute}=", configuration.send(attribute))
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ ##
25
+ # Clears all the defaults that may have been set by the user
26
+ def clear_defaults!
27
+ setter_methods.each do |method|
28
+ self.send(method, nil)
29
+ end
30
+ end
31
+
32
+ ##
33
+ # Returns an array of the setter methods (as String)
34
+ def setter_methods
35
+ methods.map do |method|
36
+ method = method.to_s
37
+ method if method =~ /^\w(\w|\d|\_)+\=$/ and method != 'taguri='
38
+ end.compact
39
+ end
40
+
41
+ ##
42
+ # Returns an array of getter methods (as Array)
43
+ def getter_methods
44
+ methods.map do |method|
45
+ method = method.to_s
46
+ if method =~ /^\w(\w|\d|\_)+\=$/ and method != 'taguri='
47
+ method.sub('=','')
48
+ end
49
+ end.compact
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Configuration
5
+ module Notifier
6
+ class Base < Backup::Configuration::Base
7
+ class << self
8
+
9
+ ##
10
+ # When set to true, the user will be notified by email
11
+ # when a backup process ends without raising any exceptions
12
+ attr_writer :on_success
13
+
14
+ ##
15
+ # When set to true, the user will be notified by email
16
+ # when a backup process raises an exception before finishing
17
+ attr_writer :on_failure
18
+
19
+ end
20
+
21
+ ##
22
+ # When @on_success is nil it means it hasn't been defined
23
+ # and will then default to true
24
+ def self.on_success
25
+ return true if @on_success.nil?
26
+ @on_success
27
+ end
28
+
29
+ ##
30
+ # When @on_failure is nil it means it hasn't been defined
31
+ # and will then default to true
32
+ def self.on_failure
33
+ return true if @on_failure.nil?
34
+ @on_failure
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Configuration
5
+ module Notifier
6
+ class Campfire < Base
7
+ class << self
8
+
9
+ ##
10
+ # Campfire api authentication token
11
+ attr_accessor :api_token
12
+
13
+ ##
14
+ # Campfire account's subdomain
15
+ attr_accessor :subdomain
16
+
17
+ ##
18
+ # Campfire account's room id
19
+ attr_accessor :room_id
20
+
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Configuration
5
+ module Notifier
6
+ class Mail < Base
7
+ class << self
8
+
9
+ ##
10
+ # Sender and Receiver email addresses
11
+ # Examples:
12
+ # sender - my.email.address@gmail.com
13
+ # receiver - your.email.address@gmail.com
14
+ attr_accessor :from, :to
15
+
16
+ ##
17
+ # The address to use
18
+ # Example: smtp.gmail.com
19
+ attr_accessor :address
20
+
21
+ ##
22
+ # The port to connect to
23
+ # Example: 587
24
+ attr_accessor :port
25
+
26
+ ##
27
+ # Your domain (if applicable)
28
+ # Example: mydomain.com
29
+ attr_accessor :domain
30
+
31
+ ##
32
+ # Username and Password (sender email's credentials)
33
+ # Examples:
34
+ # user_name - meskyanichi
35
+ # password - my_secret_password
36
+ attr_accessor :user_name, :password
37
+
38
+ ##
39
+ # Authentication type
40
+ # Example: plain
41
+ attr_accessor :authentication
42
+
43
+ ##
44
+ # Automatically set TLS
45
+ # Example: true
46
+ attr_accessor :enable_starttls_auto
47
+
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Configuration
5
+ module Notifier
6
+ class Presently < Base
7
+ class << self
8
+
9
+ ##
10
+ # Presently subdomain
11
+ attr_accessor :subdomain
12
+
13
+ ##
14
+ # Presently credentials
15
+ attr_accessor :user_name, :password
16
+
17
+ ##
18
+ # Group id
19
+ attr_accessor :group_id
20
+
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Configuration
5
+ module Notifier
6
+ class Twitter < Base
7
+ class << self
8
+
9
+ ##
10
+ # Twitter consumer key credentials
11
+ attr_accessor :consumer_key, :consumer_secret
12
+
13
+ ##
14
+ # OAuth credentials
15
+ attr_accessor :oauth_token, :oauth_token_secret
16
+
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Configuration
5
+ module Storage
6
+ class Base < Backup::Configuration::Base
7
+ class << self
8
+
9
+ ##
10
+ # Sets the limit to how many backups to keep in the remote location.
11
+ # If the limit exceeds it will remove the oldest backup to make room for the newest
12
+ attr_accessor :keep
13
+
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Configuration
5
+ module Storage
6
+ class CloudFiles < Base
7
+ class << self
8
+
9
+ ##
10
+ # Rackspace Cloud Files Credentials
11
+ attr_accessor :api_key, :username
12
+
13
+ ##
14
+ # Rackspace Cloud Files container name and path
15
+ attr_accessor :container, :path
16
+
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Configuration
5
+ module Storage
6
+ class Dropbox < Base
7
+ class << self
8
+
9
+ ##
10
+ # Dropbox user credentials
11
+ attr_accessor :email, :password
12
+
13
+ ##
14
+ # Dropbox API credentials
15
+ attr_accessor :api_key, :api_secret
16
+
17
+ ##
18
+ # Path to where the backups will be stored
19
+ attr_accessor :path
20
+
21
+ ##
22
+ # Dropbox connection timeout
23
+ attr_accessor :timeout
24
+
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ module Backup
4
+ module Configuration
5
+ module Storage
6
+ class FTP < Base
7
+ class << self
8
+
9
+ ##
10
+ # Server credentials
11
+ attr_accessor :username, :password
12
+
13
+ ##
14
+ # Server IP Address and FTP port
15
+ attr_accessor :ip, :port
16
+
17
+ ##
18
+ # Path to store backups to
19
+ attr_accessor :path
20
+
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end