struggle 2.3.6 → 2.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/struggle/backup.rb +13 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a452bc1852b7b410115dfdcd030abca2188f4695
|
4
|
+
data.tar.gz: c61ce12a7b2de6d6d10c4caa38c30dfd52d052f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc0eac6bae646c04d5f3557caab40bbc42a7d6f7cb2cc559aedaee81013b73bcd2dfbee99e0917e785d04f31a59a6c35b99f9a729819ce157bf340bbd8cdc0f1
|
7
|
+
data.tar.gz: 237a20d3a4ecbfe8c9ceaa1a9bbdea9a0cf6d4011619de9681c6f1d2036d9291c72b1f95014beaafe1119dd7e9a348b005d71e97a3e6450c3f9b59cff6931b6c
|
data/lib/struggle/backup.rb
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
# 备份数据库和文件
|
2
|
+
# 数据库配置
|
3
|
+
# mysql数据库配置
|
4
|
+
# 修改mysql配置文件 /etc/mysql/conf.d/mysqldump.cnf 在client 或者 mysqldump节点下增加host/user/password,导出时可以不用配置密码。
|
5
|
+
# [mysqldump]
|
6
|
+
# host=localhost
|
7
|
+
# user=root
|
8
|
+
# password='123456'
|
9
|
+
# postgresql数据库配置
|
10
|
+
# 在pg_hba.conf中添加用户访问认证trust(要重启),一行所有用户all,二行postgres用户
|
11
|
+
# TYPE DATABASE USER ADDRESS METHOD
|
12
|
+
# host all all 192.168.12.10/32 trust
|
13
|
+
# host all postgres 192.168.12.10/32 trust
|
2
14
|
# 生成配置文件命令 rails g struggle:sql_config
|
3
15
|
# Struggle::Backup.new.do 执行备份
|
4
16
|
module Struggle
|
@@ -22,7 +34,7 @@ module Struggle
|
|
22
34
|
_filename = "#{@@config["database"]}-#{@@now.strftime("%Y%m%d%H%M%S")}"
|
23
35
|
filename = @@config["adapter"] == "oracle_enhanced" ? "#{_filename}.dmp" : "#{_filename}.sql"
|
24
36
|
if @@config["adapter"] == "mysql2"
|
25
|
-
system("mysqldump -u#{@@config["username"]}
|
37
|
+
system("mysqldump -u#{@@config["username"]} #{@@config["database"]}>#{filename}")
|
26
38
|
elsif @@config["adapter"] == "postgresql"
|
27
39
|
system("pg_dump -U #{@@config["username"]} -d #{@@config["database"]} -E utf8 -f #{filename} -w")
|
28
40
|
elsif @@config["adapter"] == "oracle_enhanced"
|