module Struggle

备份数据库和文件 数据库配置

mysql数据库配置
  修改mysql配置文件 /etc/mysql/conf.d/mysqldump.cnf 在client 或者 mysqldump节点下增加host/user/password,导出时可以不用配置密码。
      [mysqldump]
      host=localhost
      user=root
      password='123456'
postgresql数据库配置
  在pg_hba.conf中添加用户访问认证trust(要重启),一行所有用户all,二行postgres用户
      TYPE  DATABASE    USER     ADDRESS          METHOD
      host    all       all    192.168.12.10/32    trust
      host    all     postgres   192.168.12.10/32   trust

生成配置文件命令 rails g struggle:sql_config Struggle::Backup.new.do 执行备份

first gem 'rmagick'

RSA工具,基于openssl,功能包括,秘钥生成,加密解密

导出sql文件,生成insert语句 生成配置文件命令 rails g struggle:sql_config

This is a simple example which uses rubyzip to recursively generate a zip file from the contents of a specified directory. The directory itself is not included in the archive, rather just its contents.

Usage:

directory_to_zip = "/tmp/input"
output_file = "/tmp/out.zip"
ZipTool.dir(directory_to_zip, output_file)
ZipTool.dir("1.txt", output_file)