gitti-backup 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da31fe3c40e34387650d37bac81a8a4c15ce858c
4
- data.tar.gz: 595414af6e4655bb6dddc552db194794ac31cb72
3
+ metadata.gz: 98528e760c07a1b0d66ddd120073ef829bce821a
4
+ data.tar.gz: b9e5e7e4c2cb3d88cac33b00874274623fb34a29
5
5
  SHA512:
6
- metadata.gz: 3881867d7f7513f4af361c9a15b96092ce026ed122055d960ef24f3158f777b293dda7a01c1819bf6fee6673060639c29d1720d761ee43ad7a5734d0ba7de312
7
- data.tar.gz: e4d6a6066aebdc6e12b2ddaeac156583b78bdba87fac097d80fb2875ef7b5c37983d76b8c730f7772530aa07f1e08a85f306b0ee83929c56cdcb0edaecb893a0
6
+ metadata.gz: 88be2d1aef4b657bdc49ea048c72cdd5fdaf1fcb39555302d19c7db118550597a64a1e83b8ff88a3d8114d26973f0b5da272e840d8ebc9f1eb379b05fcbdff8d
7
+ data.tar.gz: 2e51ed36028c50f21419bada59e72fed01d7e564a5a42c621073f2e42f128fe2a9fa257849be5253e479d88f73eaa109075aae3c1522d0b4a56b5e9e9f2f8a32
@@ -2,6 +2,7 @@ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
+ bin/backup
5
6
  lib/gitti/backup.rb
6
7
  lib/gitti/backup/backup.rb
7
8
  lib/gitti/backup/base.rb
data/README.md CHANGED
@@ -8,8 +8,70 @@ gitti-backup gem - (yet) another (lite) git backup command line script
8
8
  * rdoc :: [rubydoc.info/gems/gitti-backup](http://rubydoc.info/gems/gitti-backup)
9
9
 
10
10
 
11
+
11
12
  ## Usage
12
13
 
14
+ ### `backup` Command Line Tool
15
+
16
+ Use the `backup` command line tool to backup all repos listed in a "manifest" file (e.g. `repos.yml`, `code.yml`, `github.yml` or such). Example:
17
+
18
+ ```
19
+ backup repos.yml # or
20
+ backup code.yml data.yml
21
+ ```
22
+
23
+ In a nutshell backup will backup all repos by using
24
+ 1. `git clone --mirror` or
25
+ 2. `git remote update` (if the local backup already exists)
26
+ and store all bare repos (without workspace) in the `~/backup` directory.
27
+
28
+
29
+ #### Repos Manifest
30
+
31
+ For now only github repos are supported listed by
32
+ owner / organization. Example `repos.yml`:
33
+
34
+ ``` yaml
35
+ sportdb:
36
+ - sport.db
37
+ - sport.db.sources
38
+ - football.db
39
+
40
+ yorobot:
41
+ - cache.csv
42
+ - sport.db.more
43
+ - football.db
44
+ - football.csv
45
+
46
+ openfootball:
47
+ - leagues
48
+ - clubs
49
+ ```
50
+
51
+ Using `backup` with defaults this will result in:
52
+
53
+ ```
54
+ ~/backup
55
+ /sportdb
56
+ /sport.db.git
57
+ /sport.db.sources.git
58
+ /football.db.git
59
+ /yorobot
60
+ /cache.csv.git
61
+ /sport.db.more.git
62
+ /football.db.git
63
+ /football.csv.git
64
+ /openfootball
65
+ /leagues.git
66
+ /clubs.git
67
+ ```
68
+
69
+
70
+
71
+ ### Scripting
72
+
73
+ You can script your backup in ruby. Example:
74
+
13
75
 
14
76
  ``` ruby
15
77
  require 'gitti/backup'
@@ -23,6 +85,21 @@ backup = GitBackup.new
23
85
  backup.backup( GitRepoSet.read( './repos.yml' ) )
24
86
  ```
25
87
 
88
+ or
89
+
90
+ ``` ruby
91
+ require 'gitti/backup'
92
+
93
+ ## step 1: setup the root backup directory
94
+ ## 1) use custom directory e.g. /backups
95
+ ## 2) auto-add a daily directory e.g. /backups/2020-09-27
96
+ backup = GitBackup.new( '/backups', daily: true )
97
+
98
+ backup.backup( GitRepoSet.read( './repos.yml' ) )
99
+ ```
100
+
101
+
102
+
26
103
  That's all for now.
27
104
 
28
105
 
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ###################
4
+ # DEV TIPS:
5
+ #
6
+ # For local testing run like:
7
+ #
8
+ # ruby -Ilib bin/backup
9
+ #
10
+ # Set the executable bit in Linux. Example:
11
+ #
12
+ # % chmod a+x bin/backup
13
+ #
14
+
15
+ require 'gitti/backup/base'
16
+
17
+ Gitti::GitBackup::Tool.main
@@ -4,16 +4,35 @@ module Gitti
4
4
 
5
5
  class GitBackup
6
6
 
7
- def initialize( root= '~/backup' )
7
+ class Tool ## nested class
8
+ def self.main( args=ARGV )
9
+ backup = GitBackup.new
10
+ args.each do |arg|
11
+ backup.backup( GitRepoSet.read( arg ))
12
+ end
13
+ end
14
+ end ## nested class Tool
15
+
16
+
17
+
18
+ def initialize( root= '~/backup', daily: false )
8
19
  @root = File.expand_path( root )
9
20
  pp @root
10
21
 
11
22
  ## use current working dir for the log path; see do_with_log helper for use
12
23
  @log_path = File.expand_path( '.' )
13
24
  pp @log_path
25
+
26
+ @daily = daily
14
27
  end
15
28
 
16
29
 
30
+ ## auto-add "daily" date folder / dir
31
+ ## e.g. 2015-11-20 using Date.today.strftime('%Y-%m-%d')
32
+ def daily=(value) @daily=value; end
33
+
34
+
35
+
17
36
  def backup( repos )
18
37
  count_orgs = 0
19
38
  count_repos = 0
@@ -21,7 +40,8 @@ class GitBackup
21
40
  total_repos = repos.size
22
41
 
23
42
  ## default to adding folder per day ## e.g. 2015-11-20
24
- backup_path = "#{@root}/#{Date.today.strftime('%Y-%m-%d')}"
43
+ backup_path = "#{@root}"
44
+ backup_path << "/#{Date.today.strftime('%Y-%m-%d')}" if @daily
25
45
  pp backup_path
26
46
 
27
47
  FileUtils.mkdir_p( backup_path ) ## make sure path exists
@@ -3,7 +3,7 @@ module GittiBackup
3
3
 
4
4
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
5
5
  MINOR = 4
6
- PATCH = 0
6
+ PATCH = 1
7
7
  VERSION = [MAJOR,MINOR,PATCH].join('.')
8
8
 
9
9
  def self.version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitti-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
@@ -54,7 +54,8 @@ dependencies:
54
54
  version: '3.16'
55
55
  description: gitti-backup - (yet) another (lite) git backup command line script
56
56
  email: ruby-talk@ruby-lang.org
57
- executables: []
57
+ executables:
58
+ - backup
58
59
  extensions: []
59
60
  extra_rdoc_files:
60
61
  - CHANGELOG.md
@@ -65,6 +66,7 @@ files:
65
66
  - Manifest.txt
66
67
  - README.md
67
68
  - Rakefile
69
+ - bin/backup
68
70
  - lib/gitti/backup.rb
69
71
  - lib/gitti/backup/backup.rb
70
72
  - lib/gitti/backup/base.rb