Top Level Namespace
Defined Under Namespace
Modules: Backup
Instance Method Summary collapse
-
#general ⇒ Object
Backup Generated: general Once configured, you can run the backup with the following command:.
Instance Method Details
#general ⇒ Object
Backup Generated: general Once configured, you can run the backup with the following command:
$ backup perform -t general [-c <path_to_configuration_file>]
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/generators/backup/rails/templates/general.rb', line 11 Backup::Model.new(:general, 'Description for general') do Dotenv.load root_path = File.dirname(__FILE__) archive :code do |archive| archive.root root_path archive.add "." archive.exclude root_path + '/log' archive.exclude root_path + '/tmp' end compress_with Gzip do end if ENV['SSL_PASSWORD'] encrypt_with OpenSSL do |encryption| encryption.password = ENV['SSL_PASSWORD'] encryption.base64 = true encryption.salt = true end end if File.exists? root_path + "/config/database.yml" environment = 'production' dbconfig = YAML::load(ERB.new(IO.read(File.join(root_path, 'config', 'database.yml'))).result)[environment] if dbconfig['adapter'] == 'mysql2' database MySQL do |db| db.name = dbconfig['database'] db.username = dbconfig['username'] db.password = dbconfig['password'] db.host = dbconfig['host'] db.port = dbconfig['port'] db.socket = dbconfig['socket'] end elsif dbconfig['adapter'] == 'postgresql' database PostgreSQL do |db| db.name = dbconfig['database'] db.username = dbconfig['username'] db.password = dbconfig['password'] db.host = dbconfig['host'] db.port = dbconfig['port'] db.socket = dbconfig['socket'] end end end if File.exists? root_path + "/config/mongoid.yml" environment = 'production' dbconfig = YAML::load(ERB.new(IO.read(File.join(root_path, 'config', 'mongoid.yml'))).result)[environment] if dbconfig database MongoDB do |db| db.name = dbconfig['sessions']['default']['database'] db.username = dbconfig['sessions']['default']['username'] db.password = dbconfig['sessions']['default']['password'] #db.host = dbconfig['host'] #db.port = dbconfig['port'] db.ipv6 = false db.lock = false db.oplog = false end end end if ENV['LOCAL_PATH'] store_with Local do |local| local.path = ENV['LOCAL_PATH'] local.keep = 5 end end if ENV['S3_ACCESS_KEY_ID'] && ENV['S3_SECRET_ACCESS_KEY'] && ENV['S3_BUCKET'] store_with S3 do |s3| # AWS Credentials s3.access_key_id = ENV['S3_ACCESS_KEY_ID'] s3.secret_access_key = ENV['S3_SECRET_ACCESS_KEY'] # Or, to use a IAM Profile: # s3.use_iam_profile = true s3.region = ENV['S3_REGION'] s3.bucket = ENV['S3_BUCKET'] s3.path = ENV['S3_PATH'].dup end end if ENV['NOTIFY_MAIL_USER_NAME'] notify_by Mail do |mail| mail.on_success = true mail.on_warning = true mail.on_failure = true mail.from = ENV['NOTIFY_MAIL_FROM'] mail.to = ENV['NOTIFY_MAIL_TO'] mail.address = ENV['NOTIFY_MAIL_ADDRESS'] mail.port = ENV['NOTIFY_MAIL_PORT'] mail.domain = ENV['NOTIFY_MAIL_DOMAIN'] mail.user_name = ENV['NOTIFY_MAIL_USER_NAME'] mail.password = ENV['NOTIFY_MAIL_PASSWORD'] mail.authentication = ENV['NOTIFY_MAIL_AUTHENTICATION'] mail.encryption = :starttls end end end |