ruby_clone 1.0.0 → 1.0.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.
- data/README.md +215 -186
- data/lib/ruby_clone/version.rb +1 -1
- metadata +7 -7
data/README.md
CHANGED
@@ -6,18 +6,18 @@
|
|
6
6
|
|
7
7
|
Install the gem:
|
8
8
|
|
9
|
-
|
9
|
+
`gem install ruby_clone`
|
10
10
|
|
11
11
|
Create a file that is named '.ruby_clone' in your home folder and set up a profile.
|
12
12
|
**NOTE**: Don't forget to use the dot in the file.
|
13
13
|
|
14
14
|
And then execute:
|
15
15
|
|
16
|
-
|
16
|
+
`$ ruby_clone my_profile`
|
17
17
|
|
18
18
|
You can also specify another path of your **RubyClone** file:
|
19
19
|
|
20
|
-
|
20
|
+
`$ ruby_clone -b /my/ruby_clone_file my_profile`
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
@@ -31,19 +31,20 @@ To start using it, you'll need to create the following configuration in your **R
|
|
31
31
|
**NOTE 2**: If your source folder/destination_folder has spaces as "My Source Folder", you need to set up it as
|
32
32
|
"My\\ Source\\ Folder" with **two back slashes** for **each space**. Spaces and only one back slash will not work.
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
```ruby
|
35
|
+
profile :my_profile do
|
36
|
+
from "/my/source_folder/"
|
37
|
+
to "/my/destination_folder"
|
38
|
+
end
|
39
|
+
```
|
39
40
|
|
40
41
|
If you set up this configuration in your $HOME/.ruby_clone, you can run with:
|
41
42
|
|
42
|
-
|
43
|
+
`$ ruby_clone my_profile`
|
43
44
|
|
44
45
|
If is in another path, run with:
|
45
46
|
|
46
|
-
|
47
|
+
`$ ruby_clone -b /my/backup_file my_profile`
|
47
48
|
|
48
49
|
**NOTE**: This basic setup doesn't sync deleted files from the source folder. If you want to delete them, you need
|
49
50
|
to setup the option 'delete: true'.
|
@@ -53,17 +54,21 @@ to setup the option 'delete: true'.
|
|
53
54
|
**RubyClone** offers the option to use SSH in a easy way. You just need to use the option ':ssh' with the 'user@host'.
|
54
55
|
Example for SSH that is on source folder.
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
```ruby
|
58
|
+
profile :my_profile do
|
59
|
+
from "/my/source_folder/", ssh: "user@source_server"
|
60
|
+
to "/my/destination_folder"
|
61
|
+
end
|
62
|
+
```
|
60
63
|
|
61
64
|
Example for SSH that is on destination folder:
|
62
65
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
66
|
+
```ruby
|
67
|
+
profile :my_profile do
|
68
|
+
from "/my/source_folder/"
|
69
|
+
to "/my/destination_folder", ssh: "user@destination_server"
|
70
|
+
end
|
71
|
+
```
|
67
72
|
|
68
73
|
After running one of theses profiles, you just need to type the password.
|
69
74
|
|
@@ -76,225 +81,252 @@ Here is all the configuration you can set up and improve your **RubyClone** file
|
|
76
81
|
|
77
82
|
### Excluding a Pattern - exclude_pattern "pattern"
|
78
83
|
|
79
|
-
|
80
|
-
|
81
|
-
|
84
|
+
If you need to exclude folders or files matching a pattern, use the 'exclude_pattern command.
|
85
|
+
This command can be used in two ways: On the top of **RubyClone** file and/or inside the 'from'.
|
86
|
+
Here a complete example:
|
82
87
|
|
83
|
-
|
88
|
+
```ruby
|
89
|
+
exclude_pattern "top_pattern"
|
84
90
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
91
|
+
profile :my_profile1 do
|
92
|
+
from "/my/source_folder/"
|
93
|
+
to "/my/destination_folder"
|
94
|
+
end
|
89
95
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
+
profile :my_profile2 do
|
97
|
+
from "/my/source_folder/" do
|
98
|
+
exclude_pattern "from_pattern"
|
99
|
+
end
|
100
|
+
to "/my/destination_folder"
|
101
|
+
end
|
102
|
+
```
|
96
103
|
|
97
|
-
|
98
|
-
|
104
|
+
1. 'my_profile1' will exclude only the "top_pattern".
|
105
|
+
2. 'my_profile2' will exclude the "top_pattern" and "from_pattern"
|
99
106
|
|
100
107
|
### Including a Pattern - include_pattern "pattern"
|
101
108
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
109
|
+
Same as the exclude_pattern. If you need to include folders or files matching a pattern, use the
|
110
|
+
include_pattern command. This command can be use in two ways: On the top of **RubyClone** file and/or
|
111
|
+
inside the 'from' block. Example:
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
include_pattern "top_pattern"
|
115
|
+
|
116
|
+
profile :my_profile1 do
|
117
|
+
from "/my/source_folder/"
|
118
|
+
to "/my/destination_folder"
|
119
|
+
end
|
120
|
+
|
121
|
+
profile :my_profile2 do
|
122
|
+
from "/my/source_folder/" do
|
123
|
+
include_pattern "from_pattern"
|
124
|
+
end
|
125
|
+
to "/my/destination_folder"
|
126
|
+
end
|
127
|
+
```
|
128
|
+
|
129
|
+
1. 'my_profile1' will include only the "top_pattern".
|
130
|
+
2. 'my_profile2' will include the "top_pattern" and "from_pattern"
|
131
|
+
|
132
|
+
Here an example using exclude_pattern and include_pattern together. In this example, :my_profile will exclude
|
133
|
+
all folders and will sync/include only the 'from_pattern'
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
profile :my_profile do
|
137
|
+
from "/my/source_folder/" do
|
138
|
+
exclude_pattern "*"
|
139
|
+
include_pattern "from_pattern"
|
140
|
+
end
|
141
|
+
to "/my/destination_folder"
|
142
|
+
end
|
143
|
+
```
|
133
144
|
|
134
145
|
### Deleting files
|
135
146
|
|
136
|
-
|
147
|
+
* Deleting files that don't exist in source_folder but in destination folder - delete: true
|
137
148
|
|
138
|
-
|
139
|
-
|
140
|
-
|
149
|
+
The basic configuration was created to be a secure configuration. So if you really want to delete files/folders
|
150
|
+
in your destination folder that doesn't exist anymore in your source folder, you'll need to set up 'delete: true' in
|
151
|
+
your **RubyClone** file. Below an example how to do it:
|
141
152
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
153
|
+
```ruby
|
154
|
+
profile :my_profile do
|
155
|
+
from "/my/source_folder/"
|
156
|
+
to "/my/destination_folder", delete: true
|
157
|
+
end
|
158
|
+
```
|
146
159
|
|
147
|
-
|
148
|
-
|
160
|
+
Now all files that exists in "/my/destination_folder/" but "/my/source_folder" will be deleted. If for some
|
161
|
+
reason you want to keep some files and delete others, just set up the exclude_pattern inside 'from' block.
|
149
162
|
|
150
|
-
|
163
|
+
* Deleting files that are excluded from source folder to destination folder - delete_excluded: true
|
151
164
|
|
152
|
-
|
153
|
-
|
154
|
-
|
165
|
+
If you decided to exclude files from the syncronization but they still in your destination folder, you can use
|
166
|
+
the 'delete_excluded' to delete this files inside destination folder that are excluded from the source_folder.
|
167
|
+
Example:
|
155
168
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
169
|
+
```ruby
|
170
|
+
profile :my_profile do
|
171
|
+
from "/my/source_folder/" do
|
172
|
+
exclude_pattern "my_pattern"
|
173
|
+
end
|
174
|
+
to "/my/destination_folder", delete_excluded: true
|
175
|
+
end
|
176
|
+
```
|
162
177
|
|
163
|
-
|
178
|
+
Now all files that are inside destination_folder that have the pattern 'my_pattern' will be deleted.
|
164
179
|
|
165
|
-
|
166
|
-
|
180
|
+
**NOTE**: When you use 'delete_excluded :true' you don't need to set up 'delete: true' even the from
|
181
|
+
configuration doesn't have the 'exclude_pattern'
|
167
182
|
|
168
183
|
### Backuping files - backup "folder"
|
169
184
|
|
170
|
-
|
171
|
-
|
185
|
+
* If you want to save all the files that get **updated** and **deleted**, you need to set up the 'backup'
|
186
|
+
configuration inside the 'to' block. Example:
|
172
187
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
188
|
+
```ruby
|
189
|
+
profile :my_profile do
|
190
|
+
from "/my/source_folder/"
|
191
|
+
to "/my/destination_folder", delete: true do
|
192
|
+
backup "/my/backup_folder"
|
193
|
+
end
|
194
|
+
end
|
195
|
+
```
|
179
196
|
|
180
|
-
Now all the folders/files that get **updated** or **deleted** in the "/my/destination_folder" will be moved to
|
181
|
-
"/my/backup_folder". The files moved to "/my/destination_folder" will have a default suffix that is a **RubyClone**
|
182
|
-
control key plus the Date with the format: "yyyyMMdd".
|
183
197
|
|
184
|
-
|
185
|
-
|
198
|
+
Now all the folders/files that get **updated** or **deleted** in the "/my/destination_folder" will be moved to
|
199
|
+
"/my/backup_folder". The files moved to "/my/destination_folder" will have a default suffix that is a **RubyClone**
|
200
|
+
control key plus the Date with the format: "yyyyMMdd".
|
186
201
|
|
187
|
-
|
202
|
+
All files that are saved in the "/my/backup_folder" will have a limit of 5 files. So if any file that passed this
|
203
|
+
limit, the old file will be deleted. You can change this limit using the option "limit".
|
188
204
|
|
189
|
-
|
205
|
+
**NOTE**: The **RubyClone** control key is a special key to use as a control to remove old duplicated files.
|
190
206
|
|
191
|
-
|
192
|
-
Example:
|
207
|
+
* Changing the suffix of the files inside the backup folder - backup "folder", suffix: "my_suffix"
|
193
208
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
209
|
+
If you want to change the Date suffix for the files that you backup, you need to set the 'suffix' as a parameter to 'backup'.
|
210
|
+
Example:
|
211
|
+
|
212
|
+
```ruby
|
213
|
+
profile :my_profile do
|
214
|
+
from "/my/source_folder/"
|
215
|
+
to "/my/destination_folder", delete: true do
|
216
|
+
backup "/my/backup_folder", suffix: "my_suffix"
|
217
|
+
end
|
218
|
+
end
|
219
|
+
```
|
200
220
|
|
201
|
-
|
221
|
+
Another example using suffix with the Time class of Ruby to generate the date with timestamp "yyyyMMdd_hhmmss" :
|
202
222
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
223
|
+
```ruby
|
224
|
+
profile :my_profile do
|
225
|
+
from "/my/source_folder/"
|
226
|
+
to "/my/destination_folder", delete: true do
|
227
|
+
backup "/my/backup_folder", suffix: "_#{Time.now.strftime("%Y%m%d_%H%M%S")}"
|
228
|
+
end
|
229
|
+
end
|
230
|
+
```
|
209
231
|
|
210
|
-
|
211
|
-
|
232
|
+
**NOTE**: Changing the suffix will not change the **RubyClone** control key. Since this key control how to remove the
|
233
|
+
old duplicated files.
|
212
234
|
|
213
|
-
|
235
|
+
* Disabling the default suffix - backup "folder", disable_suffix: true
|
214
236
|
|
215
|
-
|
237
|
+
If for some reason you want to disable the file suffix in the backup folder you can set true for 'default_true'. Doing
|
216
238
|
that all the files that are moved to "/my/backup_folder" will have the same name and it will get override by a new file.
|
217
239
|
Example:
|
218
240
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
241
|
+
```ruby
|
242
|
+
profile :my_profile do
|
243
|
+
from "/my/source_folder/"
|
244
|
+
to "/my/destination_folder", delete: true do
|
245
|
+
backup "/my/backup_folder", disable_suffix: true
|
246
|
+
end
|
247
|
+
end
|
248
|
+
```
|
225
249
|
|
226
|
-
|
250
|
+
**NOTE**: This kind of setup will **backup only one file** and nothing more.
|
227
251
|
|
228
|
-
|
252
|
+
* Changing how many files you want to backup - backup "folder", limit: 10
|
229
253
|
|
230
|
-
|
231
|
-
|
232
|
-
|
254
|
+
**RubyClone** have a default to save 5 files "/my/backup_folder" that have the same name. If you want to change the
|
255
|
+
limit you just need to set up the option limit with the number of files to save.
|
256
|
+
Example:
|
233
257
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
258
|
+
```ruby
|
259
|
+
profile :my_profile do
|
260
|
+
from "/my/source_folder/"
|
261
|
+
to "/my/destination_folder", delete: true do
|
262
|
+
backup "/my/backup_folder", limit: 20
|
263
|
+
end
|
264
|
+
end
|
265
|
+
```
|
240
266
|
|
241
|
-
|
267
|
+
Now "/my/backup_folder" will save 20 files with the same name.
|
242
268
|
|
243
|
-
|
269
|
+
* Disabling the limit of files to save. Save unlimited files - backup "folder", limit: :unlimited
|
244
270
|
|
245
|
-
|
246
|
-
|
247
|
-
|
271
|
+
If for some reason you want to backup all files that are **updated** or **deleted** you need to set up the 'limit'
|
272
|
+
option with ':unlimited'
|
273
|
+
Example:
|
248
274
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
275
|
+
```ruby
|
276
|
+
profile :my_profile do
|
277
|
+
from "/my/source_folder/"
|
278
|
+
to "/my/destination_folder", delete: true do
|
279
|
+
backup "/my/backup_folder", limit: :unlimited
|
280
|
+
end
|
281
|
+
end
|
282
|
+
```
|
255
283
|
|
256
|
-
|
257
|
-
|
284
|
+
Now all files will be saved, until you change the 'limit' to a specific number to erased all the old files that passed
|
285
|
+
the new limit.
|
258
286
|
|
259
287
|
### Disabling the output commands of RSync - config options
|
260
288
|
|
261
|
-
|
262
|
-
|
263
|
-
|
289
|
+
* **RubyClone** offers the possibility to not show the rsync command generated (show_command) and rsync output
|
290
|
+
(show_output). To use it, you need to set up in the top of your **RubyClone** file the 'config' and the commands you
|
291
|
+
want to disable. Example:
|
264
292
|
|
265
|
-
|
293
|
+
```ruby
|
294
|
+
config show_command: false, show_output: false
|
266
295
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
296
|
+
profile :my_profile do
|
297
|
+
from "/my/source_folder/"
|
298
|
+
to "/my/destination_folder"
|
299
|
+
end
|
300
|
+
```
|
271
301
|
|
272
|
-
|
273
|
-
|
302
|
+
The above config will not show anymore the rsync command and rsync outputs. But errors will keep showing if
|
303
|
+
happen.
|
274
304
|
|
275
|
-
|
305
|
+
* Overriding the default configuration of Rsync command - config options: 'override_options'
|
276
306
|
|
277
|
-
|
278
|
-
|
307
|
+
If you need to override the default configurations for RSync you can set up the "config options: 'my_options'".
|
308
|
+
Example:
|
279
309
|
|
280
|
-
|
310
|
+
```ruby
|
311
|
+
config options: '-Cav --stats'
|
281
312
|
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
313
|
+
profile :my_profile do
|
314
|
+
from "/my/source_folder/"
|
315
|
+
to "/my/destination_folder"
|
316
|
+
end
|
317
|
+
```
|
286
318
|
|
287
319
|
## Running
|
288
320
|
|
289
321
|
**RubyClone** as default will try to read the **RubyClone** file in your home folder: $HOME/.ruby_clone. If you
|
290
322
|
need to specify another path of your **RubyClone** file don't forget to add the option -b
|
291
323
|
|
292
|
-
|
324
|
+
`$ ruby_clone -b /my/ruby_clone_file profile`
|
293
325
|
|
294
326
|
RSync offers the options to dry-run the command and just run the sincronization as a simulation. You can do this
|
295
327
|
too with **RubyClone**. Just pass the option '-d' to ruby_clone
|
296
328
|
|
297
|
-
|
329
|
+
`$ ruby_clone -d profile`
|
298
330
|
|
299
331
|
## More interesting **RubyClone** file
|
300
332
|
|
@@ -306,19 +338,16 @@ it will copy the 'source_folder' inside the 'destination_folder. (This behaviour
|
|
306
338
|
**NOTE 2**: If your source folder/destination_folder has spaces as "/My Source Folder", you need to set up it as
|
307
339
|
"My\\ Source\\ Folder" with **two back slashes** for **each space**. Spaces and only one back slash will not work.
|
308
340
|
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
Even this script were has been tested many times, you run this script entirely at your own risk.
|
321
|
-
**RubyClone** accepts no responsibility for any damage this script may cause.
|
341
|
+
```ruby
|
342
|
+
profile :my_profile do
|
343
|
+
from "/my/source_folder/" do
|
344
|
+
exclude_pattern "pattern"
|
345
|
+
end
|
346
|
+
to "/my/destination_folder", delete_excluded: true do
|
347
|
+
backup "/my/backup"
|
348
|
+
end
|
349
|
+
end
|
350
|
+
```
|
322
351
|
|
323
352
|
## Contributing to **RubyClone**
|
324
353
|
|
@@ -326,4 +355,4 @@ it will copy the 'source_folder' inside the 'destination_folder. (This behaviour
|
|
326
355
|
|
327
356
|
## Copyright
|
328
357
|
|
329
|
-
Copyright (c) 2012 Frederico Benevides. See MIT-LICENSE for further details.
|
358
|
+
Copyright (c) 2012 Frederico Benevides. See MIT-LICENSE for further details.
|
data/lib/ruby_clone/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_clone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-09-24 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
16
|
-
requirement: &
|
16
|
+
requirement: &70236612351040 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.3.2
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70236612351040
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: guard-rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70236612350320 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.2.1
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70236612350320
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70236612349580 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 2.11.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70236612349580
|
47
47
|
description: Ruby clone is a command line tool to work with Rsync using DSL!
|
48
48
|
email:
|
49
49
|
- fredbene@gmail.com
|