backup 2.3.3.1 → 2.4.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/CHANGELOG +6 -0
- data/README.md +7 -1
- data/VERSION +1 -1
- data/bin/backup +4 -2
- data/generators/backup/backup_generator.rb +5 -8
- data/generators/backup/templates/{tasks/backup.rake → backup.rake} +11 -7
- data/generators/backup/templates/{config/backup.rb → backup.rb} +10 -0
- data/generators/backup/templates/{migrations/create_backup_tables.rb → create_backup_tables.rb} +0 -0
- data/lib/backup.rb +43 -33
- data/lib/backup/environment/base.rb +1 -1
- data/lib/backup/environment/{rails.rb → rails_configuration.rb} +4 -6
- data/lib/backup/environment/{unix.rb → unix_configuration.rb} +1 -1
- data/lib/generators/backup/USAGE +10 -0
- data/lib/generators/backup/backup_generator.rb +47 -0
- data/lib/generators/backup/templates/backup.rake +56 -0
- data/lib/generators/backup/templates/backup.rb +229 -0
- data/lib/generators/backup/templates/create_backup_tables.rb +18 -0
- data/setup/backup.rb +1 -0
- metadata +16 -12
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,13 @@
|
|
2
2
|
|
3
3
|
## A Backup Ruby Gem
|
4
4
|
|
5
|
-
|
5
|
+
__Backup__ is a Ruby Gem written for __Unix__ and __Ruby on Rails (2 and 3)__ environments. It can be used both with and without the Ruby on Rails framework! This gem offers a quick and simple solution to backing up databases such as MySQL/PostgreSQL/SQLite and Files/Folders. All backups can be transferred to Amazon S3, Rackspace Cloud Files, any remote server you have access to (using either SCP, SFTP or regular FTP), or a Local server. Backup handles Compression, Archiving, Encryption, Backup Cleaning (Cycling) and supports Email Notifications.
|
6
|
+
|
7
|
+
## Written for Environments
|
8
|
+
|
9
|
+
* UNIX (Ubuntu, OSX, etc.)
|
10
|
+
* Ruby on Rails 3
|
11
|
+
* Ruby on Rails 2
|
6
12
|
|
7
13
|
## Authors/Maintainers
|
8
14
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.4.0
|
data/bin/backup
CHANGED
@@ -3,8 +3,10 @@
|
|
3
3
|
require 'optparse'
|
4
4
|
require 'backup'
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
Backup::System.boot!
|
7
|
+
|
8
|
+
include Backup::Environment::UnixConfiguration::Commands
|
9
|
+
include Backup::Environment::UnixConfiguration::Helpers
|
8
10
|
|
9
11
|
options = {}
|
10
12
|
|
@@ -13,17 +13,16 @@ class BackupGenerator < Rails::Generator::Base
|
|
13
13
|
|
14
14
|
# Generates the Rake Tasks and Backup Database
|
15
15
|
m.directory "lib/tasks"
|
16
|
-
m.
|
17
|
-
m.file "tasks/backup.rake", "lib/tasks/backup/backup.rake"
|
16
|
+
m.file "backup.rake", "lib/tasks/backup.rake"
|
18
17
|
|
19
18
|
# Generates the configuration file
|
20
19
|
m.directory "config"
|
21
|
-
m.file "
|
20
|
+
m.file "backup.rb", "config/backup.rb"
|
22
21
|
|
23
22
|
# Generates the database migration file
|
24
|
-
m.migration_template
|
25
|
-
|
26
|
-
|
23
|
+
m.migration_template "create_backup_tables.rb",
|
24
|
+
"db/migrate",
|
25
|
+
:migration_file_name => "create_backup_tables"
|
27
26
|
|
28
27
|
# Outputs the generators message to the terminal
|
29
28
|
puts message
|
@@ -34,7 +33,6 @@ class BackupGenerator < Rails::Generator::Base
|
|
34
33
|
<<-MESSAGE
|
35
34
|
|
36
35
|
|
37
|
-
|
38
36
|
==============================================================
|
39
37
|
Backup's files have been generated!
|
40
38
|
==============================================================
|
@@ -65,7 +63,6 @@ class BackupGenerator < Rails::Generator::Base
|
|
65
63
|
==============================================================
|
66
64
|
|
67
65
|
|
68
|
-
|
69
66
|
MESSAGE
|
70
67
|
end
|
71
68
|
|
@@ -1,13 +1,17 @@
|
|
1
1
|
namespace :backup do
|
2
|
-
|
2
|
+
|
3
|
+
task :boot => :environment do
|
4
|
+
Backup::System.boot!
|
5
|
+
end
|
6
|
+
|
3
7
|
desc "Run Backup Procedure."
|
4
|
-
task :run => :
|
8
|
+
task :run => :boot do
|
5
9
|
puts "Running: #{ENV['trigger']}."
|
6
10
|
Backup::Setup.new(ENV['trigger'], @backup_procedures).initialize_adapter
|
7
11
|
end
|
8
12
|
|
9
13
|
desc "Finds backup records by trigger"
|
10
|
-
task :find => :
|
14
|
+
task :find => :boot do
|
11
15
|
puts "Finding backup records with trigger: #{ENV['trigger']}."
|
12
16
|
backup = Backup::Setup.new(ENV['trigger'], @backup_procedures)
|
13
17
|
records = backup.procedure.record_class.all( :conditions => {:trigger => ENV['trigger']} )
|
@@ -22,26 +26,26 @@ namespace :backup do
|
|
22
26
|
end
|
23
27
|
|
24
28
|
desc "Truncates all records for the specified \"trigger\", excluding the physical files on s3 or the remote server."
|
25
|
-
task :truncate => :
|
29
|
+
task :truncate => :boot do
|
26
30
|
puts "Truncating backup records with trigger: #{ENV['trigger']}."
|
27
31
|
Backup::Record::Base.destroy_all :trigger => ENV['trigger']
|
28
32
|
end
|
29
33
|
|
30
34
|
desc "Truncates everything."
|
31
|
-
task :truncate_all => :
|
35
|
+
task :truncate_all => :boot do
|
32
36
|
puts "Truncating all backup records."
|
33
37
|
Backup::Record::Base.destroy_all
|
34
38
|
end
|
35
39
|
|
36
40
|
desc "Destroys all records for the specified \"trigger\", including the physical files on s3 or the remote server."
|
37
|
-
task :destroy => :
|
41
|
+
task :destroy => :boot do
|
38
42
|
puts "Destroying backup records with trigger: #{ENV['trigger']}."
|
39
43
|
backup = Backup::Setup.new(ENV['trigger'], @backup_procedures)
|
40
44
|
backup.procedure.record_class.destroy_all_backups( backup.procedure, ENV['trigger'] )
|
41
45
|
end
|
42
46
|
|
43
47
|
desc "Destroys all records for the specified \"trigger\", including the physical files on s3 or the remote server."
|
44
|
-
task :destroy_all => :
|
48
|
+
task :destroy_all => :boot do
|
45
49
|
puts "Destroying all backup records."
|
46
50
|
backup = Backup::Setup.new(false, @backup_procedures)
|
47
51
|
backup.procedures.each do |backup_procedure|
|
@@ -31,6 +31,7 @@
|
|
31
31
|
# GLOBAL OPTIONS
|
32
32
|
# - Keep Backups (keep_backups)
|
33
33
|
# - Encrypt With Pasword (encrypt_with_password)
|
34
|
+
# - Encrypt With GPG Public Key (encrypt_with_gpg_public_key)
|
34
35
|
# - Notify (notify)
|
35
36
|
#
|
36
37
|
# This is the "decrypt" command for all encrypted backups:
|
@@ -119,6 +120,15 @@ backup 'mysql-backup-cloudfiles' do
|
|
119
120
|
api_key 'api_key'
|
120
121
|
container 'mysql_backup'
|
121
122
|
end
|
123
|
+
|
124
|
+
encrypt_with_gpg_public_key <<-KEY
|
125
|
+
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
126
|
+
Version: GnuPG v1.4.7 (Darwin)
|
127
|
+
|
128
|
+
Your very long public key goes here
|
129
|
+
-----END PGP PUBLIC KEY BLOCK-----
|
130
|
+
KEY
|
131
|
+
|
122
132
|
end
|
123
133
|
|
124
134
|
# Initialize with:
|
data/generators/backup/templates/{migrations/create_backup_tables.rb → create_backup_tables.rb}
RENAMED
File without changes
|
data/lib/backup.rb
CHANGED
@@ -1,46 +1,56 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
BACKUP_SYSTEM = Proc.new do
|
2
|
+
# Load Gems
|
3
|
+
require 'hirb'
|
3
4
|
|
4
|
-
# Load Environments
|
5
|
-
require 'backup/environment/base'
|
6
|
-
require 'backup/environment/
|
7
|
-
require 'backup/environment/
|
5
|
+
# Load Environments
|
6
|
+
require 'backup/environment/base'
|
7
|
+
require 'backup/environment/unix_configuration'
|
8
|
+
require 'backup/environment/rails_configuration'
|
8
9
|
|
9
|
-
# Load Configuration
|
10
|
-
require 'backup/configuration/attributes'
|
11
|
-
require 'backup/configuration/base'
|
12
|
-
require 'backup/configuration/adapter'
|
13
|
-
require 'backup/configuration/adapter_options'
|
14
|
-
require 'backup/configuration/storage'
|
15
|
-
require 'backup/configuration/mail'
|
16
|
-
require 'backup/configuration/smtp'
|
17
|
-
require 'backup/configuration/helpers'
|
10
|
+
# Load Configuration
|
11
|
+
require 'backup/configuration/attributes'
|
12
|
+
require 'backup/configuration/base'
|
13
|
+
require 'backup/configuration/adapter'
|
14
|
+
require 'backup/configuration/adapter_options'
|
15
|
+
require 'backup/configuration/storage'
|
16
|
+
require 'backup/configuration/mail'
|
17
|
+
require 'backup/configuration/smtp'
|
18
|
+
require 'backup/configuration/helpers'
|
18
19
|
|
19
|
-
require 'backup/command_helper'
|
20
|
+
require 'backup/command_helper'
|
20
21
|
|
21
|
-
# Include the Configuration and Environment Helpers
|
22
|
-
include Backup::Configuration::Helpers
|
23
|
-
include Backup::Environment::Base
|
22
|
+
# Include the Configuration and Environment Helpers
|
23
|
+
include Backup::Configuration::Helpers
|
24
|
+
include Backup::Environment::Base
|
24
25
|
|
25
|
-
# Load either UNIX or RAILS environment configuration
|
26
|
-
case current_environment
|
27
|
-
|
28
|
-
|
29
|
-
end
|
26
|
+
# Load either UNIX or RAILS environment configuration
|
27
|
+
case current_environment
|
28
|
+
when :unix then include Backup::Environment::UnixConfiguration
|
29
|
+
when :rails then include Backup::Environment::RailsConfiguration
|
30
|
+
end
|
30
31
|
|
31
|
-
# Load configuration
|
32
|
-
if File.exist?(File.join(BACKUP_PATH, 'config', 'backup.rb'))
|
33
|
-
|
34
|
-
end
|
32
|
+
# Load configuration
|
33
|
+
if File.exist?(File.join(BACKUP_PATH, 'config', 'backup.rb'))
|
34
|
+
require File.join(BACKUP_PATH, 'config', 'backup.rb')
|
35
|
+
end
|
35
36
|
|
36
|
-
# Load Mail Notifier
|
37
|
-
require 'backup/mail/base'
|
37
|
+
# Load Mail Notifier
|
38
|
+
require 'backup/mail/base'
|
38
39
|
|
39
|
-
# Set Mail Configuration (extracted from the backup.rb configuration file) inside the Mail Class
|
40
|
-
Backup::Mail::Base.setup(@mail_configuration)
|
40
|
+
# Set Mail Configuration (extracted from the backup.rb configuration file) inside the Mail Class
|
41
|
+
Backup::Mail::Base.setup(@mail_configuration)
|
42
|
+
end
|
41
43
|
|
42
44
|
# Backup Module
|
43
45
|
module Backup
|
46
|
+
|
47
|
+
class System
|
48
|
+
def self.boot!
|
49
|
+
BACKUP_SYSTEM.call
|
50
|
+
true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
44
54
|
module Adapters
|
45
55
|
autoload :Base, 'backup/adapters/base'
|
46
56
|
autoload :MySQL, 'backup/adapters/mysql'
|
@@ -95,7 +105,7 @@ module Backup
|
|
95
105
|
exit
|
96
106
|
end
|
97
107
|
end
|
98
|
-
|
108
|
+
|
99
109
|
# Scans through all the backup settings and returns the backup setting
|
100
110
|
# that was specified in the "trigger" argument.
|
101
111
|
# If an non-existing trigger is specified, it will raise an error and display
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module Backup
|
2
2
|
module Environment
|
3
|
-
module
|
3
|
+
module RailsConfiguration
|
4
4
|
|
5
|
-
if defined?
|
6
|
-
|
7
|
-
|
8
|
-
BACKUP_PATH = RAILS_ROOT
|
5
|
+
if defined?(Rails.root)
|
6
|
+
# Sets BACKUP_PATH equal to Rails.root
|
7
|
+
BACKUP_PATH = Rails.root.to_s
|
9
8
|
|
10
9
|
# Sets DB_CONNECTION_SETTINGS to false
|
11
10
|
DB_CONNECTION_SETTINGS = false
|
12
|
-
|
13
11
|
end
|
14
12
|
|
15
13
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class BackupGenerator < Rails::Generators::Base
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
|
4
|
+
def copy_files
|
5
|
+
copy_file 'backup.rake', 'lib/tasks/backup.rake'
|
6
|
+
copy_file 'backup.rb', 'config/backup.rb'
|
7
|
+
|
8
|
+
unless Dir["#{Rails.root}/db/migrate/*create_backup_tables.rb"].any?
|
9
|
+
copy_file 'create_backup_tables.rb', "db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_backup_tables.rb"
|
10
|
+
end
|
11
|
+
|
12
|
+
puts message
|
13
|
+
end
|
14
|
+
|
15
|
+
def message
|
16
|
+
<<-MESSAGE
|
17
|
+
|
18
|
+
|
19
|
+
==============================================================
|
20
|
+
Backup's files have been generated!
|
21
|
+
==============================================================
|
22
|
+
|
23
|
+
1: Migrate the database!
|
24
|
+
|
25
|
+
rake db:migrate
|
26
|
+
|
27
|
+
|
28
|
+
2: Set up some "Backup Settings" inside the backup configuration file!
|
29
|
+
|
30
|
+
config/backup.rb
|
31
|
+
|
32
|
+
|
33
|
+
3: Run the backups! Enjoy.
|
34
|
+
|
35
|
+
rake backup:run trigger="your-specified-trigger"
|
36
|
+
|
37
|
+
|
38
|
+
For More Information:
|
39
|
+
http://github.com/meskyanichi/backup
|
40
|
+
|
41
|
+
==============================================================
|
42
|
+
|
43
|
+
|
44
|
+
MESSAGE
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
namespace :backup do
|
2
|
+
|
3
|
+
task :boot => :environment do
|
4
|
+
Backup::System.boot!
|
5
|
+
end
|
6
|
+
|
7
|
+
desc "Run Backup Procedure."
|
8
|
+
task :run => :boot do
|
9
|
+
puts "Running: #{ENV['trigger']}."
|
10
|
+
Backup::Setup.new(ENV['trigger'], @backup_procedures).initialize_adapter
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Finds backup records by trigger"
|
14
|
+
task :find => :boot do
|
15
|
+
puts "Finding backup records with trigger: #{ENV['trigger']}."
|
16
|
+
backup = Backup::Setup.new(ENV['trigger'], @backup_procedures)
|
17
|
+
records = backup.procedure.record_class.all( :conditions => {:trigger => ENV['trigger']} )
|
18
|
+
|
19
|
+
if ENV['table'].eql?("true")
|
20
|
+
puts Hirb::Helpers::AutoTable.render(records)
|
21
|
+
else
|
22
|
+
records.each do |record|
|
23
|
+
puts record.to_yaml
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Truncates all records for the specified \"trigger\", excluding the physical files on s3 or the remote server."
|
29
|
+
task :truncate => :boot do
|
30
|
+
puts "Truncating backup records with trigger: #{ENV['trigger']}."
|
31
|
+
Backup::Record::Base.destroy_all :trigger => ENV['trigger']
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Truncates everything."
|
35
|
+
task :truncate_all => :boot do
|
36
|
+
puts "Truncating all backup records."
|
37
|
+
Backup::Record::Base.destroy_all
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "Destroys all records for the specified \"trigger\", including the physical files on s3 or the remote server."
|
41
|
+
task :destroy => :boot do
|
42
|
+
puts "Destroying backup records with trigger: #{ENV['trigger']}."
|
43
|
+
backup = Backup::Setup.new(ENV['trigger'], @backup_procedures)
|
44
|
+
backup.procedure.record_class.destroy_all_backups( backup.procedure, ENV['trigger'] )
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "Destroys all records for the specified \"trigger\", including the physical files on s3 or the remote server."
|
48
|
+
task :destroy_all => :boot do
|
49
|
+
puts "Destroying all backup records."
|
50
|
+
backup = Backup::Setup.new(false, @backup_procedures)
|
51
|
+
backup.procedures.each do |backup_procedure|
|
52
|
+
backup_procedure.record_class.destroy_all_backups( backup_procedure, backup_procedure.trigger )
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,229 @@
|
|
1
|
+
# Backup Configuration File
|
2
|
+
#
|
3
|
+
# Use the "backup" block to add backup settings to the configuration file.
|
4
|
+
# The argument before the "do" in (backup "argument" do) is called a "trigger".
|
5
|
+
# This acts as the identifier for the configuration.
|
6
|
+
#
|
7
|
+
# In the example below we have a "mysql-backup-s3" trigger for the backup setting.
|
8
|
+
# All the configuration is done inside this block. To initialize the backup process for this block,
|
9
|
+
# you invoke it using the following rake task:
|
10
|
+
#
|
11
|
+
# rake backup:run trigger="mysql-backup-s3"
|
12
|
+
#
|
13
|
+
# You can add as many backup block settings as you want, just be sure every trigger is unique and you can run
|
14
|
+
# each of them separately.
|
15
|
+
#
|
16
|
+
# ADAPTERS
|
17
|
+
# - MySQL
|
18
|
+
# - PostgreSQL
|
19
|
+
# - SQLite
|
20
|
+
# - Archive
|
21
|
+
# - Custom
|
22
|
+
#
|
23
|
+
# STORAGE METHODS
|
24
|
+
# - S3 (Amazon)
|
25
|
+
# - CF (Rackspace Cloud Files)
|
26
|
+
# - SCP (Remote Server)
|
27
|
+
# - FTP (Remote Server)
|
28
|
+
# - SFTP (Remote Server)
|
29
|
+
# - LOCAL (Local Server)
|
30
|
+
#
|
31
|
+
# GLOBAL OPTIONS
|
32
|
+
# - Keep Backups (keep_backups)
|
33
|
+
# - Encrypt With Pasword (encrypt_with_password)
|
34
|
+
# - Encrypt With GPG Public Key (encrypt_with_gpg_public_key)
|
35
|
+
# - Notify (notify)
|
36
|
+
#
|
37
|
+
# This is the "decrypt" command for all encrypted backups:
|
38
|
+
# sudo backup --decrypt /path/to/encrypted/file
|
39
|
+
#
|
40
|
+
# Each Backup Setting can contain:
|
41
|
+
# - 1 Adapter
|
42
|
+
# - 1 Storage Method
|
43
|
+
# - Multiple Global Options
|
44
|
+
#
|
45
|
+
# The combination of these, however, do not matter! So experiment with it.
|
46
|
+
#
|
47
|
+
# You can also let Backup notify you by email on successfully created backups.
|
48
|
+
# - Just uncomment the block of code below (notifier_settings) and fill in your credentials.
|
49
|
+
# - Then for set "notify" to "true" in each (backup) block you wish to be notified of.
|
50
|
+
#
|
51
|
+
# For more information on "Backup", please refer to the wiki on github
|
52
|
+
# http://wiki.github.com/meskyanichi/backup/configuration-file
|
53
|
+
|
54
|
+
|
55
|
+
# Notifier
|
56
|
+
# Uncomment this if you want to enable notification by email on successful backup runs
|
57
|
+
# You will also have to set "notify true" inside each backup block below to enable it for that particular backup
|
58
|
+
# notifier_settings do
|
59
|
+
#
|
60
|
+
# to "example1@gmail.com"
|
61
|
+
# from "example2@gmail.com"
|
62
|
+
#
|
63
|
+
# smtp do
|
64
|
+
# host "smtp.gmail.com"
|
65
|
+
# port "587"
|
66
|
+
# username "example1@gmail.com"
|
67
|
+
# password "example1password"
|
68
|
+
# authentication "plain"
|
69
|
+
# domain "localhost.localdomain"
|
70
|
+
# tls true
|
71
|
+
# end
|
72
|
+
#
|
73
|
+
# end
|
74
|
+
|
75
|
+
|
76
|
+
# Initialize with:
|
77
|
+
# rake backup:run trigger='mysql-backup-s3'
|
78
|
+
backup 'mysql-backup-s3' do
|
79
|
+
|
80
|
+
adapter :mysql do
|
81
|
+
user 'user'
|
82
|
+
password 'password'
|
83
|
+
database 'database'
|
84
|
+
|
85
|
+
# skip_tables ['table1', 'table2', 'table3']
|
86
|
+
#
|
87
|
+
# options do
|
88
|
+
# host '123.45.678.90'
|
89
|
+
# port '80'
|
90
|
+
# socket '/tmp/socket.sock'
|
91
|
+
# end
|
92
|
+
# additional_options '--single-transaction --quick'
|
93
|
+
end
|
94
|
+
|
95
|
+
storage :s3 do
|
96
|
+
access_key_id 'access_key_id'
|
97
|
+
secret_access_key 'secret_access_key'
|
98
|
+
bucket '/bucket/backups/mysql/'
|
99
|
+
use_ssl true
|
100
|
+
end
|
101
|
+
|
102
|
+
keep_backups 25
|
103
|
+
encrypt_with_password 'password'
|
104
|
+
notify false
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
# Initialize with:
|
109
|
+
# rake backup:run trigger='mysql-backup-cloudfiles'
|
110
|
+
backup 'mysql-backup-cloudfiles' do
|
111
|
+
|
112
|
+
adapter :mysql do
|
113
|
+
user 'user'
|
114
|
+
password 'password'
|
115
|
+
database 'database'
|
116
|
+
end
|
117
|
+
|
118
|
+
storage :cloudfiles do
|
119
|
+
username 'username'
|
120
|
+
api_key 'api_key'
|
121
|
+
container 'mysql_backup'
|
122
|
+
end
|
123
|
+
|
124
|
+
encrypt_with_gpg_public_key <<-KEY
|
125
|
+
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
126
|
+
Version: GnuPG v1.4.7 (Darwin)
|
127
|
+
|
128
|
+
Your very long public key goes here
|
129
|
+
-----END PGP PUBLIC KEY BLOCK-----
|
130
|
+
KEY
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
# Initialize with:
|
135
|
+
# rake backup:run trigger='postgresql-backup-s3'
|
136
|
+
backup 'postgresql-backup-scp' do
|
137
|
+
|
138
|
+
adapter :postgresql do
|
139
|
+
user 'user'
|
140
|
+
database 'database'
|
141
|
+
|
142
|
+
# skip_tables ['table1', 'table2', 'table3']
|
143
|
+
|
144
|
+
# options do
|
145
|
+
# host '123.45.678.90'
|
146
|
+
# port '80'
|
147
|
+
# socket '/tmp/socket.sock'
|
148
|
+
# end
|
149
|
+
# additional_options '--clean --blobs'
|
150
|
+
end
|
151
|
+
|
152
|
+
storage :scp do
|
153
|
+
ip 'example.com'
|
154
|
+
user 'user'
|
155
|
+
password 'password'
|
156
|
+
path '/var/backups/postgresql/'
|
157
|
+
end
|
158
|
+
|
159
|
+
keep_backups :all
|
160
|
+
encrypt_with_password false
|
161
|
+
notify false
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
# Initialize with:
|
167
|
+
# rake backup:run trigger='archive-backup-ftp'
|
168
|
+
backup 'archive-backup-ftp' do
|
169
|
+
|
170
|
+
adapter :archive do
|
171
|
+
files ["#{RAILS_ROOT}/log", "#{RAILS_ROOT}/db"]
|
172
|
+
end
|
173
|
+
|
174
|
+
storage :ftp do
|
175
|
+
ip 'example.com'
|
176
|
+
user 'user'
|
177
|
+
password 'password'
|
178
|
+
path '/var/backups/archive/'
|
179
|
+
end
|
180
|
+
|
181
|
+
keep_backups 10
|
182
|
+
encrypt_with_password false
|
183
|
+
notify false
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
# Initialize with:
|
189
|
+
# rake backup:run trigger='custom-backup-sftp'
|
190
|
+
backup 'custom-backup-sftp' do
|
191
|
+
|
192
|
+
adapter :custom do
|
193
|
+
commands \
|
194
|
+
[ "mysqldump [options] [database] > :tmp_path/my_mysql_dump.sql",
|
195
|
+
"pg_dump [options] [database] > :tmp_path/my_postgresql_dump.sql",
|
196
|
+
"any_other_db_format [options] [database] > :tmp_path/my_any_other_db_format.sql" ]
|
197
|
+
end
|
198
|
+
|
199
|
+
storage :sftp do
|
200
|
+
ip 'example.com'
|
201
|
+
user 'user'
|
202
|
+
password 'password'
|
203
|
+
path '/var/backups/custom/'
|
204
|
+
end
|
205
|
+
|
206
|
+
keep_backups :all
|
207
|
+
encrypt_with_password 'password'
|
208
|
+
notify false
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
|
213
|
+
# Initializ with:
|
214
|
+
# rake backup:run trigger='sqlite-backup-local'
|
215
|
+
backup 'sqlite-backup-local' do
|
216
|
+
|
217
|
+
adapter :sqlite do
|
218
|
+
database "#{RAILS_ROOT}/db/production.sqlite3"
|
219
|
+
end
|
220
|
+
|
221
|
+
storage :local do
|
222
|
+
path "/path/to/storage/location/"
|
223
|
+
end
|
224
|
+
|
225
|
+
keep_backups :all
|
226
|
+
encrypt_with_password false
|
227
|
+
notify false
|
228
|
+
|
229
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateBackupTables < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :backup do |t|
|
4
|
+
t.string :trigger
|
5
|
+
t.string :adapter
|
6
|
+
t.string :filename
|
7
|
+
t.string :md5sum
|
8
|
+
t.string :path
|
9
|
+
t.string :bucket
|
10
|
+
t.string :type
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
drop_table :backup
|
17
|
+
end
|
18
|
+
end
|
data/setup/backup.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
-
|
10
|
-
|
11
|
-
version: 2.3.3.1
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 2.4.0
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- Michael van Rooijen
|
@@ -16,7 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-23 00:00:00 +02:00
|
20
19
|
default_executable:
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
@@ -163,7 +162,7 @@ dependencies:
|
|
163
162
|
type: :runtime
|
164
163
|
version_requirements: *id009
|
165
164
|
description: |-
|
166
|
-
Backup is a Ruby Gem written for Unix and Rails environments. It can be used both with
|
165
|
+
Backup is a Ruby Gem written for Unix and Ruby on Rails (2 and 3) environments. It can be used both with
|
167
166
|
and without the Ruby on Rails framework! This gem offers a quick and simple solution to backing up databases
|
168
167
|
such as MySQL/PostgreSQL/SQLite and Files/Folders. All backups can be transferred to Amazon S3, Rackspace Cloud Files,
|
169
168
|
any remote server you have access to (using either SCP, SFTP or regular FTP), or a Local server. Backup handles
|
@@ -198,8 +197,8 @@ files:
|
|
198
197
|
- lib/backup/connection/cloudfiles.rb
|
199
198
|
- lib/backup/connection/s3.rb
|
200
199
|
- lib/backup/environment/base.rb
|
201
|
-
- lib/backup/environment/
|
202
|
-
- lib/backup/environment/
|
200
|
+
- lib/backup/environment/rails_configuration.rb
|
201
|
+
- lib/backup/environment/unix_configuration.rb
|
203
202
|
- lib/backup/mail/base.rb
|
204
203
|
- lib/backup/mail/mail.txt
|
205
204
|
- lib/backup/record/base.rb
|
@@ -217,11 +216,16 @@ files:
|
|
217
216
|
- lib/backup/storage/scp.rb
|
218
217
|
- lib/backup/storage/sftp.rb
|
219
218
|
- lib/backup.rb
|
219
|
+
- lib/generators/backup/backup_generator.rb
|
220
|
+
- lib/generators/backup/templates/backup.rake
|
221
|
+
- lib/generators/backup/templates/backup.rb
|
222
|
+
- lib/generators/backup/templates/create_backup_tables.rb
|
223
|
+
- lib/generators/backup/USAGE
|
220
224
|
- bin/backup
|
221
225
|
- generators/backup/backup_generator.rb
|
222
|
-
- generators/backup/templates/
|
223
|
-
- generators/backup/templates/
|
224
|
-
- generators/backup/templates/
|
226
|
+
- generators/backup/templates/backup.rake
|
227
|
+
- generators/backup/templates/backup.rb
|
228
|
+
- generators/backup/templates/create_backup_tables.rb
|
225
229
|
- generators/backup_update/backup_update_generator.rb
|
226
230
|
- generators/backup_update/templates/migrations/update_backup_tables.rb
|
227
231
|
- setup/backup.rb
|