安装Backup v4.x

Backup v4.x 数据库备份工具

安装命令

sudo apt install ruby
ruby -v
sudo gem update --system
gem -v
sudo gem install backup
sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt-get update
sudo apt-get install ruby2.2 ruby2.2-dev
ruby -v
sudo gem install backup

backup generate:model --trigger my_backup --databases="mysql, postgresql" --storages="local" --compressor="gzip" --notifiers="mail"

backup perform --trigger my_backup

model文件

# encoding: utf-8

##
# Backup Generated: my_backup
# Once configured, you can run the backup with the following command:
#
# $ backup perform -t my_backup [-c ]
#
# For more information about Backup's components, see the documentation at:
# http://backup.github.io/backup
#
Model.new(:my_backup, 'Description for my_backup') do

  ##
  # MySQL [Database]
  #
  database MySQL do |db|
    # To dump all databases, set `db.name = :all` (or leave blank)
    db.name               = "你的数据库名称"
    db.username           = "你的数据库用户"
    db.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

  ##
  # PostgreSQL [Database]
  #
  database PostgreSQL do |db|
    # To dump all databases, set `db.name = :all` (or leave blank)
    db.name               = "你的数据库"
    db.username           = "你的数据库用户"
    db.password           = "你的数据库密码"
    db.host               = "127.0.0.1"
    db.port               = 5432
    #db.socket             = "/var/run/postgresql"
    # When dumping all databases, `skip_tables` and `only_tables` are ignored.
    #db.skip_tables        = ["skip", "these", "tables"]
    #db.only_tables        = ["only", "these", "tables"]
    db.additional_options = ["-xc", "-E=utf8"]
  end

  ##
  # Local (Copy) [Storage]
  #
  store_with Local do |local|
    local.path       = "~/backups/"
    local.keep       = 5
    # local.keep       = Time.now - 2592000 # Remove all backups older than 1 month.
  end

  ##
  # Gzip [Compressor]
  #
  compress_with Gzip

  ##
  # Mail [Notifier]
  #
  # The default delivery method for Mail Notifiers is 'SMTP'.
  # See the documentation for other delivery options.
  #
  notify_by Mail do |mail|
    mail.on_success           = true
    mail.on_warning           = true
    mail.on_failure           = true

    mail.from                 = "发送邮件的邮箱地址"
    mail.to                   = "接收邮件的邮箱地址"
    #mail.cc                   = "[email protected]"
    #mail.bcc                  = "[email protected]"
    #mail.reply_to             = "[email protected]"
    mail.address              = "smtp.gmail.com"
    mail.port                 = 587
    mail.domain               = "localhost"
    mail.user_name            = "发送邮件的邮箱地址"
    mail.password             = "邮箱密码"
    mail.authentication       = "plain"
    mail.encryption           = :starttls
  end

end

你可能感兴趣的:(安装Backup v4.x)