redash_backup 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -1
- data/Gemfile +2 -5
- data/Gemfile.lock +26 -44
- data/README.md +24 -3
- data/Rakefile +10 -1
- data/lib/redash_backup.rb +2 -1
- data/lib/redash_backup/base.rb +6 -6
- data/lib/redash_backup/version.rb +1 -1
- data/redash_backup.gemspec +4 -8
- metadata +21 -64
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f36f9eeebbd9fa0be5a711cd32b0675c9ceaa279c8d69995969a60965138ce6
|
4
|
+
data.tar.gz: 6f44e27b0139dbfe55d63ed9a6139d77671d733abe074dfed9b6076b52181ca6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2935e1f86598239f8fc8d7a91a4d548835faa338bff76636d78b4514c49e81f95bce87482dbc59d762b33f7fbe64bc7498e27c0cfd82fe733430bee120ed0925
|
7
|
+
data.tar.gz: 0536d95831121e13a62a9deba8087a7f0a13127f48a0fc52fe6ef2bef5c0a55b4033bd71ed0789831103490d1a45437e0f7a80d2e8d44a6ce5d1d3b83592cc37
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,62 +1,44 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
redash_backup (0.
|
5
|
-
activerecord
|
6
|
-
fileutils
|
7
|
-
pg
|
4
|
+
redash_backup (0.2.0)
|
5
|
+
activerecord
|
6
|
+
fileutils
|
7
|
+
pg
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activemodel (6.
|
13
|
-
activesupport (= 6.
|
14
|
-
activerecord (6.
|
15
|
-
activemodel (= 6.
|
16
|
-
activesupport (= 6.
|
17
|
-
activesupport (6.
|
12
|
+
activemodel (6.1.3)
|
13
|
+
activesupport (= 6.1.3)
|
14
|
+
activerecord (6.1.3)
|
15
|
+
activemodel (= 6.1.3)
|
16
|
+
activesupport (= 6.1.3)
|
17
|
+
activesupport (6.1.3)
|
18
18
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
|
-
i18n (>=
|
20
|
-
minitest (
|
21
|
-
tzinfo (~>
|
22
|
-
zeitwerk (~> 2.
|
23
|
-
concurrent-ruby (1.1.
|
24
|
-
|
25
|
-
|
26
|
-
i18n (1.8.2)
|
19
|
+
i18n (>= 1.6, < 2)
|
20
|
+
minitest (>= 5.1)
|
21
|
+
tzinfo (~> 2.0)
|
22
|
+
zeitwerk (~> 2.3)
|
23
|
+
concurrent-ruby (1.1.8)
|
24
|
+
fileutils (1.5.0)
|
25
|
+
i18n (1.8.9)
|
27
26
|
concurrent-ruby (~> 1.0)
|
28
|
-
minitest (5.14.
|
29
|
-
pg (1.2.
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
rspec-expectations (~> 3.9.0)
|
34
|
-
rspec-mocks (~> 3.9.0)
|
35
|
-
rspec-core (3.9.1)
|
36
|
-
rspec-support (~> 3.9.1)
|
37
|
-
rspec-expectations (3.9.0)
|
38
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
-
rspec-support (~> 3.9.0)
|
40
|
-
rspec-mocks (3.9.1)
|
41
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
-
rspec-support (~> 3.9.0)
|
43
|
-
rspec-support (3.9.2)
|
44
|
-
thread_safe (0.3.6)
|
45
|
-
tzinfo (1.2.6)
|
46
|
-
thread_safe (~> 0.1)
|
47
|
-
zeitwerk (2.2.2)
|
27
|
+
minitest (5.14.4)
|
28
|
+
pg (1.2.3)
|
29
|
+
tzinfo (2.0.4)
|
30
|
+
concurrent-ruby (~> 1.0)
|
31
|
+
zeitwerk (2.4.2)
|
48
32
|
|
49
33
|
PLATFORMS
|
50
34
|
ruby
|
35
|
+
x86_64-darwin-19
|
51
36
|
|
52
37
|
DEPENDENCIES
|
53
38
|
activerecord
|
54
|
-
|
55
|
-
|
56
|
-
pg (>= 0.18, < 2.0)
|
57
|
-
rake (~> 13.0)
|
39
|
+
fileutils
|
40
|
+
pg
|
58
41
|
redash_backup!
|
59
|
-
rspec (~> 3.0)
|
60
42
|
|
61
43
|
BUNDLED WITH
|
62
|
-
|
44
|
+
2.2.9
|
data/README.md
CHANGED
@@ -19,10 +19,31 @@ Or install it yourself as:
|
|
19
19
|
$ gem install redash_backup
|
20
20
|
|
21
21
|
## Usage
|
22
|
+
### With other than zsh
|
23
|
+
- YOUR_REDEDASH_DATABASE_URL is like postgres://username:password@host:port/db
|
22
24
|
|
25
|
+
```sh
|
26
|
+
rake redash:backup[YOUR_REDEDASH_DATABASE_URL,EXPORT_DIR_NAME]
|
27
|
+
#
|
28
|
+
# export...
|
29
|
+
#
|
30
|
+
# ./queries/dashboard1/hoge.sql
|
31
|
+
# ./queries/dashboard1/page.sql
|
32
|
+
# ./queries/dashboard2/poko.sql
|
33
|
+
# ./queries/dashboard2/pako.sql
|
34
|
+
# ./queries/unused/maru.sql
|
35
|
+
# ./queries/unused/batu.sql
|
36
|
+
#
|
37
|
+
# ※ default export path: './queries'
|
38
|
+
# Can call without 'EXPORT DIR NAME'
|
39
|
+
# ex. rake redash:backup['YOUR REDEDASH DATABASE_URL']
|
23
40
|
```
|
24
|
-
|
25
|
-
|
41
|
+
|
42
|
+
### With zsh
|
43
|
+
|
44
|
+
```sh
|
45
|
+
※ Surround with single quotes
|
46
|
+
rake 'redash:backup[YOUR_REDEDASH_DATABASE_URL,EXPORT_DIR_NAME]'
|
26
47
|
#
|
27
48
|
# export...
|
28
49
|
#
|
@@ -35,4 +56,4 @@ Or install it yourself as:
|
|
35
56
|
#
|
36
57
|
# ※ default export path: './queries'
|
37
58
|
#
|
38
|
-
```
|
59
|
+
```
|
data/Rakefile
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
+
require "redash_backup"
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
5
6
|
|
6
|
-
|
7
|
+
namespace :redash do
|
8
|
+
task :query_backup, [:db_url, :export_dir] do |task, args|
|
9
|
+
RedashBackup.new(args.db_url).execute(args.export_dir)
|
10
|
+
end
|
11
|
+
|
12
|
+
task :db_backup, [:db_url, :expoet_dir] do |task, args|
|
13
|
+
RedashBackup.new(args.db_url).db_dump(args.export_dir)
|
14
|
+
end
|
15
|
+
end
|
data/lib/redash_backup.rb
CHANGED
data/lib/redash_backup/base.rb
CHANGED
@@ -11,31 +11,31 @@ class RedashBackup::Base
|
|
11
11
|
def export
|
12
12
|
FileUtils.rm_r(@dir) if Dir.exist? @dir
|
13
13
|
Dir.mkdir(@dir)
|
14
|
-
|
15
|
-
boards.each { |board| export_by_board!(board) }
|
14
|
+
Dashboard.active.all.find_each { |board| export_by_board!(board) }
|
16
15
|
export_unused_queries!
|
17
16
|
end
|
18
17
|
|
19
18
|
private
|
20
19
|
|
21
20
|
def export_by_board!(board)
|
22
|
-
|
21
|
+
board_name = board.name.gsub('/', '_')
|
22
|
+
Dir.mkdir(@dir + '/' + board_name)
|
23
23
|
board.widgets.each do |widget|
|
24
24
|
query = widget.visualization&.query
|
25
25
|
next unless query
|
26
26
|
|
27
27
|
text = <<~TEXT
|
28
|
-
-- #{
|
28
|
+
-- #{board_name}
|
29
29
|
-- #{query.name}
|
30
30
|
-- #{Time.now.strftime('%Y/%m/%d %H:%M')}
|
31
31
|
|
32
32
|
#{query.query}
|
33
33
|
TEXT
|
34
|
-
File.open(@dir + "/#{
|
34
|
+
File.open(@dir + "/#{board_name}/#{query.name.gsub('/', '_')}.sql", 'w') do |file|
|
35
35
|
file.puts text
|
36
36
|
end
|
37
37
|
end
|
38
|
-
puts "Completed export to #{@dir}/#{
|
38
|
+
puts "Completed export to #{@dir}/#{board_name}/*.sql"
|
39
39
|
end
|
40
40
|
|
41
41
|
# unused: queries not attach to dashboard
|
data/redash_backup.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Tashiro"]
|
10
10
|
spec.email = ["g4160hc@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = 'Simple Redash\'s query backup
|
12
|
+
spec.summary = 'Simple tool for Redash\'s query backup'
|
13
13
|
spec.description = 'cli for back up redash queries'
|
14
14
|
spec.homepage = 'https://github.com/tashirosota/ruby-redash_backup'
|
15
15
|
spec.license = "MIT"
|
@@ -33,11 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.bindir = "exe"
|
34
34
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
35
|
spec.require_paths = ["lib"]
|
36
|
-
spec.add_dependency "
|
37
|
-
spec.add_dependency "
|
38
|
-
spec.add_dependency
|
39
|
-
|
40
|
-
spec.add_development_dependency "bundler", "~> 1.17"
|
41
|
-
spec.add_development_dependency "rake", "~> 13.0"
|
42
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
spec.add_dependency "pg"
|
37
|
+
spec.add_dependency "activerecord"
|
38
|
+
spec.add_dependency "fileutils"
|
43
39
|
end
|
metadata
CHANGED
@@ -1,99 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redash_backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tashiro
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: pg
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: fileutils
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.7.2
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: bundler
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.17'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.17'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rake
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '13.0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '13.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rspec
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '3.0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
52
|
+
- - ">="
|
95
53
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
54
|
+
version: '0'
|
97
55
|
description: cli for back up redash queries
|
98
56
|
email:
|
99
57
|
- g4160hc@gmail.com
|
@@ -103,7 +61,6 @@ extra_rdoc_files: []
|
|
103
61
|
files:
|
104
62
|
- ".gitignore"
|
105
63
|
- ".rspec"
|
106
|
-
- ".travis.yml"
|
107
64
|
- CHANGELOG.md
|
108
65
|
- CODE_OF_CONDUCT.md
|
109
66
|
- Gemfile
|
@@ -125,7 +82,7 @@ metadata:
|
|
125
82
|
homepage_uri: https://github.com/tashirosota/ruby-redash_backup
|
126
83
|
source_code_uri: https://github.com/tashirosota/ruby-redash_backup
|
127
84
|
changelog_uri: https://github.com/tashirosota/ruby-redash_backup/blob/master/CHANGELOG.md
|
128
|
-
post_install_message:
|
85
|
+
post_install_message:
|
129
86
|
rdoc_options: []
|
130
87
|
require_paths:
|
131
88
|
- lib
|
@@ -140,8 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
97
|
- !ruby/object:Gem::Version
|
141
98
|
version: '0'
|
142
99
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
144
|
-
signing_key:
|
100
|
+
rubygems_version: 3.1.2
|
101
|
+
signing_key:
|
145
102
|
specification_version: 4
|
146
|
-
summary: Simple Redash's query backup
|
103
|
+
summary: Simple tool for Redash's query backup
|
147
104
|
test_files: []
|