Skip to content

Instantly share code, notes, and snippets.

@r6m
Created November 27, 2015 06:00
Show Gist options
  • Save r6m/b49a807cafc25fb2055b to your computer and use it in GitHub Desktop.
Save r6m/b49a807cafc25fb2055b to your computer and use it in GitHub Desktop.
generate backup model
$ backup generate:model --trigger backup_name\
--databases="mysql" --storages="dropbox" \
--compressor="gzip" --notifiers="mail"
# encoding: utf-8
##
# Backup Generated: backup_name
# Once configured, you can run the backup with the following command:
#
# $ backup perform -t backup_name [-c <path_to_configuration_file>]
#
Backup::Model.new(:backup_name, 'Backup description') do
##
# Split [Splitter]
#
# Split the backup file in to chunks of 250 megabytes
# if the backup file size exceeds 250 megabytes
#
split_into_chunks_of 250
##
# MySQL [Database]
#
database MySQL do |db|
# To dump all databases, set `db.name = :all` (or leave blank)
db.name = "database_name"
db.username = "root"
db.password = "password"
db.host = "localhost"
db.port = 3306
db.socket = "/var/run/mysqld/mysqld.sock"
# Note: when using `skip_tables` with the `db.name = :all` option,
# table names should be prefixed with a database name.
# e.g. ["db_name.table_to_skip", ...]
# db.skip_tables = ["skip", "these", "tables"]
# db.only_tables = ["only", "these", "tables"]
db.additional_options = ["--quick", "--single-transaction"]
end
##
# Dropbox File Hosting Service [Storage]
#
# Access Type:
#
# - :app_folder (Default)
# - :dropbox
#
# Note:
#
# Initial backup must be performed manually to authorize
# this machine with your Dropbox account.
#
store_with Dropbox do |db|
db.api_key = "your_api_key"
db.api_secret = "your_api_secret"
db.access_type = :app_folder
db.path = "/backups"
db.keep = 25
end
##
# Gzip [Compressor]
#
compress_with Gzip
##
# Mail [Notifier]
#
# The default delivery method for Mail Notifiers is 'SMTP'.
# See the Wiki for other delivery options.
# https://github.com/meskyanichi/backup/wiki/Notifiers
#
notify_by Mail do |mail|
mail.on_success = true
mail.on_warning = true
mail.on_failure = true
mail.from = "[email protected]"
mail.to = "[email protected]"
mail.address = "smtp.gmail.com"
mail.port = 587
mail.domain = "sample.ir"
mail.user_name = "[email protected]"
mail.password = "sender_password"
mail.authentication = "plain"
mail.encryption = :starttls
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment