easy_sync 0.0.1 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cea7195f628ae1bb09b15c6fc14d8a97217d20f8
4
- data.tar.gz: 6bdd4d0fb5a0ad7149196b817aadcc5d367d2a7d
3
+ metadata.gz: db70fafbe7f01c1a85a67e87359fe01c9350c216
4
+ data.tar.gz: d816bd69fbfed00dce75711fa981e31ab2695881
5
5
  SHA512:
6
- metadata.gz: 9977a20cc1c688e8e5d1767c4b8533643da3b071f990d59ba6b037bb95f76d3f70844b741ad28aea86316fef7899ac3441390eed7377a7173be95384135143f2
7
- data.tar.gz: 22bac584e4ba65fad6d642aaf758b401864b6d615697af1b28b25c00bde5705bea7ef8c2ad7d6ec99723e39b6bfdfe2cde36be9d0d2744b839f44e0564636b45
6
+ metadata.gz: de345960d2bd1f0db051f8281efcce82a3bd48dde7d90a6315bca62e22de9a3f435018bf54b90683502c4018cf097007573cd08d835f60013447ce2d69ccef81
7
+ data.tar.gz: 875f30a9c1e8235f7c2e76edc1278578e7a7307aff396648a3695c67a9fa80ad0cfa587a1af971a011258366acf1f1419433cd4462c991d0993a18dac3555de8
data/README.md CHANGED
@@ -20,7 +20,7 @@ Now if you use **Ruby** plus **Rsync** you can easily have many cold snapshots t
20
20
 
21
21
 
22
22
  ### Usage
23
- Just run easy_sync to generate a template mapping file, configure
23
+ Just run **easy_sync** to generate a template mapping file, configure
24
24
  your paths and next time you run **easy_sync** it will create the first
25
25
  backup. After first backup it will create incremental backups.
26
26
 
@@ -1,4 +1,5 @@
1
1
  require 'logger'
2
+ require 'fileutils'
2
3
 
3
4
  module EasySync
4
5
 
@@ -14,13 +15,23 @@ module EasySync
14
15
  end
15
16
 
16
17
  def latest_snapshot
17
- @last_snapshot = Dir["#{destination}/*"].max_by{|s| File.mtime s}
18
+ @last_snapshot = Dir["#{destination}/*"].max
18
19
  end
19
20
 
20
21
  def current_snapshot
21
22
  @current = File.join destination, Time.now.strftime("%Y-%m-%d")
22
23
  end
23
24
 
25
+ def remove_old_backups
26
+ backups = Dir["#{destination}/*"]
27
+
28
+ (backups - backups.last(5)).each do |r|
29
+ puts "Removing #{r}"
30
+ FileUtils.remove_dir(r, true)
31
+ end
32
+
33
+ end
34
+
24
35
  def sync
25
36
  commands = [
26
37
  "rsync",
@@ -33,8 +44,11 @@ module EasySync
33
44
  commands << ["#{source}", "#{current_snapshot}"]
34
45
  commands = commands.flatten
35
46
 
36
- name = "\n\n\n------------------ Running #{sync_name} ------------------\n\n\n"
37
- puts name
47
+ puts "\n\n\n------------------ Running #{sync_name} ------------------\n\n\n"
48
+
49
+ remove_old_backups
50
+
51
+ puts "latest snapshot #{@last_snapshot}"
38
52
 
39
53
  IO.popen(commands).each_line do |l|
40
54
  puts l
@@ -1,3 +1,3 @@
1
1
  module EasySync
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Espejo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-06 00:00:00.000000000 Z
11
+ date: 2014-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  requirements: []
115
115
  rubyforge_project:
116
- rubygems_version: 2.2.2
116
+ rubygems_version: 2.4.5
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: Ruby wrapper around rsync to easily create incremental backups.