github_snapshot 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/Gemfile +0 -1
- data/README.md +36 -2
- data/github_snapshot.gemspec +3 -5
- data/lib/github_snapshot/organization.rb +2 -3
- data/lib/github_snapshot/repository.rb +5 -3
- data/lib/github_snapshot/snapshot.rb +3 -1
- data/lib/github_snapshot/version.rb +1 -1
- metadata +6 -33
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjA2YjVjZjU1YTFmNWNiNTdiMjg5OTVhM2ZlNjRiNTk1ZjczYjkwZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Yjc0MTg5ZDFiNzcyYTg3MWFlYWFiZjA1ZTRkMzg0ZjU5Yjk4NzU1ZA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGIxYTA0MTJiZTkxMWJkNzJmMmVjNjg4Y2ZiMGMxNTA1MmI5NDE0NTc4YWQ4
|
10
|
+
YWYyNGFiNGNhOWQyNjAyMTcxMjk1YWQ3NTg0N2IxNzIwNTU0NTEyNGRiNTcy
|
11
|
+
NDczOWZiOTg0OTYyMTY0MmVjM2QxZGZjNzExYTM1N2E4M2ZlN2U=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OGRiMjViOTZiZmQ4ZTk3N2QxYWI1YjZjYWQ2YjNhNWQ4YWJjYzUzM2ViMTIw
|
14
|
+
OTEwNmIxMTJmMGE0ZjI4YmIwOGYzMmVjOTQwNTIzMzZjZTIxYzM4YTQxOTNl
|
15
|
+
Y2U5OWE0M2NjOWRlNmFiMGI5OWNhNTU0ZDk4YWJhYjRiZDlhZDg=
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,36 @@
|
|
1
1
|
# GithubSnapshot
|
2
2
|
|
3
|
-
|
3
|
+
Snapshots multiple organizations GitHub repositories, including wikis, and syncs them to Amazon's S3. The gem also prunes old backups, keeping only the N most recent snapshots for each repository.
|
4
|
+
|
5
|
+
Please do keep in mind that we are not setting up an additional remote that is kept in sync. We do a `git clone --mirror` on each repository and then gzip it with a timestamp. Here is a typical (and reduced for clarity) tree structure of the backup folder/S3 bucket:
|
6
|
+
|
7
|
+
```
|
8
|
+
github-backups/
|
9
|
+
├── mozilla
|
10
|
+
│ ├── brick-201308260300.git.tar.gz
|
11
|
+
│ ├── brick-201308260300.wiki.git.tar.gz
|
12
|
+
│ ├── brick-201308270300.git.tar.gz
|
13
|
+
│ ├── brick-201308270300.wiki.git.tar.gz
|
14
|
+
│ ├── shumway-201308260300.git.tar.gz
|
15
|
+
│ ├── shumway-201308260300.wiki.git.tar.gz
|
16
|
+
│ ├── shumway-201308270300.git.tar.gz
|
17
|
+
│ ├── shumway-201308270300.wiki.git.tar.gz
|
18
|
+
└── innvent
|
19
|
+
├── github_snapshot-201308260300.git.tar.gz
|
20
|
+
├── github_snapshot-201308270300.git.tar.gz
|
21
|
+
├── matross-201308260300.git.tar.gz
|
22
|
+
├── matross-201308270300.git.tar.gz
|
23
|
+
└── jobs-201308260300.git.tar.gz
|
24
|
+
└── jobs-201308270300.git.tar.gz
|
25
|
+
```
|
4
26
|
|
5
27
|
## Installation
|
6
28
|
|
7
29
|
`github_snapshot` should be run as a command line tool, so it makes sense installing it globally
|
8
30
|
|
9
|
-
|
31
|
+
```bash
|
32
|
+
$ gem install github_snapshot
|
33
|
+
```
|
10
34
|
|
11
35
|
[`s3cmd`](https://github.com/s3tools/s3cmd) should also be installed on the system and properly configured.
|
12
36
|
|
@@ -37,6 +61,16 @@ $ github_snapshot
|
|
37
61
|
$ echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
38
62
|
```
|
39
63
|
|
64
|
+
## To-Do
|
65
|
+
|
66
|
+
Although this gem was created to serve a very specific purpose at Innvent, here is the roadmap we have in mind:
|
67
|
+
|
68
|
+
- Tests;
|
69
|
+
- Backup GitHub issues;
|
70
|
+
- Flag based configuration, in addition to the YAML config file;
|
71
|
+
- Turn off S3 synchronization;
|
72
|
+
- Restore backups to GitHub;
|
73
|
+
|
40
74
|
## Contributing
|
41
75
|
|
42
76
|
1. Fork it
|
data/github_snapshot.gemspec
CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = GithubSnapshot::VERSION
|
9
9
|
spec.authors = ["Artur Rodrigues" , "Joao Sa"]
|
10
10
|
spec.email = ["arturhoo@gmail.com"]
|
11
|
-
spec.description = %q{
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.homepage = ""
|
11
|
+
spec.description = %q{Snapshots multiple organizations GitHub repositories, including wikis, and syncs them to Amazon's S3}
|
12
|
+
spec.summary = %q{Snapshots Github repositories}
|
13
|
+
spec.homepage = "https://github.com/innvent/github_snapshot"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
@@ -19,10 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
-
spec.add_development_dependency "rake"
|
23
22
|
spec.add_development_dependency "pry"
|
24
23
|
spec.add_development_dependency "awesome_print"
|
25
24
|
|
26
25
|
spec.add_dependency "github_api", "~> 0.10.2"
|
27
|
-
spec.add_dependency "rake"
|
28
26
|
end
|
@@ -12,7 +12,7 @@ module GithubSnapshot
|
|
12
12
|
|
13
13
|
def initialize(repo, organization)
|
14
14
|
@name = repo['name']
|
15
|
-
@folder = "#{
|
15
|
+
@folder = "#{@name}-#{GithubSnapshot.time_now}.git"
|
16
16
|
@wiki_folder = @folder.gsub('.git', '.wiki.git')
|
17
17
|
@ssh_url = repo['ssh_url']
|
18
18
|
@wiki_ssh_url = @ssh_url.gsub('.git', '.wiki.git')
|
@@ -35,9 +35,11 @@ module GithubSnapshot
|
|
35
35
|
return nil
|
36
36
|
end
|
37
37
|
|
38
|
+
Dir.chdir "#{organization.name}"
|
38
39
|
clone
|
39
40
|
clone_wiki if self.has_wiki?
|
40
41
|
prune_old_backups
|
42
|
+
Dir.chdir ".."
|
41
43
|
|
42
44
|
GithubSnapshot.logger.info "#{canonical_name} - success"
|
43
45
|
end
|
@@ -66,13 +68,13 @@ module GithubSnapshot
|
|
66
68
|
|
67
69
|
def prune_old_backups
|
68
70
|
GithubSnapshot.logger.info "#{canonical_name} - pruning old backups"
|
69
|
-
file_regex = "#{
|
71
|
+
file_regex = "#{name}*"
|
70
72
|
zipped_bkps = FileList[file_regex].exclude(/wiki/)
|
71
73
|
zipped_bkps.sort[0..-(GithubSnapshot.releases_to_keep + 1)].each do |file|
|
72
74
|
File.delete file
|
73
75
|
end if zipped_bkps.length > GithubSnapshot.releases_to_keep
|
74
76
|
|
75
|
-
wiki_regex = "#{
|
77
|
+
wiki_regex = "#{name}*wiki*"
|
76
78
|
zipped_wikis = FileList[wiki_regex]
|
77
79
|
zipped_wikis.sort[0..-(GithubSnapshot.releases_to_keep + 1)].each do |file|
|
78
80
|
File.delete file
|
@@ -79,13 +79,15 @@ module GithubSnapshot
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def backup_orgs
|
82
|
+
Dir.chdir "#{backup_folder}"
|
82
83
|
organizations.each do |org|
|
83
84
|
GithubSnapshot.logger.info "#{org} - initializing"
|
84
85
|
repos = github.repos.list org: org
|
85
|
-
organization = Organization.new org,
|
86
|
+
organization = Organization.new org, repos
|
86
87
|
organization.backup
|
87
88
|
GithubSnapshot.logger.info "#{org} - ending"
|
88
89
|
end
|
90
|
+
Dir.chdir ".."
|
89
91
|
end
|
90
92
|
|
91
93
|
def upload_to_s3
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github_snapshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artur Rodrigues
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -25,20 +25,6 @@ dependencies:
|
|
25
25
|
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.3'
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: rake
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - ! '>='
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '0'
|
35
|
-
type: :development
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ! '>='
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '0'
|
42
28
|
- !ruby/object:Gem::Dependency
|
43
29
|
name: pry
|
44
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,21 +67,8 @@ dependencies:
|
|
81
67
|
- - ~>
|
82
68
|
- !ruby/object:Gem::Version
|
83
69
|
version: 0.10.2
|
84
|
-
|
85
|
-
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
88
|
-
- - ! '>='
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: '0'
|
91
|
-
type: :runtime
|
92
|
-
prerelease: false
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
94
|
-
requirements:
|
95
|
-
- - ! '>='
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '0'
|
98
|
-
description: Snapshoting organization's repositories, including wikis
|
70
|
+
description: Snapshots multiple organizations GitHub repositories, including wikis,
|
71
|
+
and syncs them to Amazon's S3
|
99
72
|
email:
|
100
73
|
- arturhoo@gmail.com
|
101
74
|
executables:
|
@@ -116,7 +89,7 @@ files:
|
|
116
89
|
- lib/github_snapshot/snapshot.rb
|
117
90
|
- lib/github_snapshot/utilities.rb
|
118
91
|
- lib/github_snapshot/version.rb
|
119
|
-
homepage:
|
92
|
+
homepage: https://github.com/innvent/github_snapshot
|
120
93
|
licenses:
|
121
94
|
- MIT
|
122
95
|
metadata: {}
|
@@ -139,5 +112,5 @@ rubyforge_project:
|
|
139
112
|
rubygems_version: 2.0.7
|
140
113
|
signing_key:
|
141
114
|
specification_version: 4
|
142
|
-
summary:
|
115
|
+
summary: Snapshots Github repositories
|
143
116
|
test_files: []
|