remotebackup 0.5.1 → 0.50.2
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/History.txt +8 -1
- data/Manifest.txt +3 -17
- data/{README.txt → README.rdoc} +162 -162
- data/Rakefile +26 -3
- data/bin/remote_backup +0 -0
- data/bin/restore_backup +0 -0
- data/lib/remotebackup.rb +64 -33
- data/script/console +0 -0
- data/script/destroy +0 -0
- data/script/generate +0 -0
- data/test/test_helper.rb +1 -0
- metadata +91 -68
- data/License.txt +0 -20
- data/config/hoe.rb +0 -73
- data/config/requirements.rb +0 -15
- data/lib/remotebackup/version.rb +0 -9
- data/script/txt2html +0 -82
- data/setup.rb +0 -1585
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/website/index.html +0 -11
- data/website/index.txt +0 -83
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.html.erb +0 -48
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -1,27 +1,13 @@
|
|
1
1
|
History.txt
|
2
|
-
License.txt
|
3
2
|
Manifest.txt
|
4
3
|
PostInstall.txt
|
5
|
-
README.
|
4
|
+
README.rdoc
|
6
5
|
Rakefile
|
7
|
-
config/hoe.rb
|
8
|
-
config/requirements.rb
|
9
6
|
lib/remotebackup.rb
|
10
|
-
lib/remotebackup/version.rb
|
11
|
-
bin/remote_backup
|
12
|
-
bin/restore_backup
|
13
7
|
script/console
|
14
8
|
script/destroy
|
15
9
|
script/generate
|
16
|
-
|
17
|
-
|
18
|
-
tasks/deployment.rake
|
19
|
-
tasks/environment.rake
|
20
|
-
tasks/website.rake
|
10
|
+
bin/remote_backup
|
11
|
+
bin/restore_backup
|
21
12
|
test/test_helper.rb
|
22
13
|
test/test_remotebackup.rb
|
23
|
-
website/index.html
|
24
|
-
website/index.txt
|
25
|
-
website/javascripts/rounded_corners_lite.inc.js
|
26
|
-
website/stylesheets/screen.css
|
27
|
-
website/template.html.erb
|
data/{README.txt → README.rdoc}
RENAMED
@@ -1,162 +1,162 @@
|
|
1
|
-
= remote_backup
|
2
|
-
|
3
|
-
* http://net-ssh.rubyforge.org/remotebackup
|
4
|
-
|
5
|
-
== DESCRIPTION:
|
6
|
-
|
7
|
-
remote ssh backup is backup files on remote server with ssh. It's not required any program on remote server.Only download files which changed size or mday. And you can restore not only last version but also past version.
|
8
|
-
|
9
|
-
== FEATURES/PROBLEMS:
|
10
|
-
* Transfer files or entire directory trees from a remote host via SCP
|
11
|
-
* Configurete server,path,user,password and ignore directory or files by xml.
|
12
|
-
* remote_backup makes backup file tree information by yaml named yyyymmdd.yml in repository + backup name
|
13
|
-
* restore_backup read backup file tree information and reconstruct from repository to outputdir.
|
14
|
-
* Make backup file tree information when more than one files are changed on remote server from last backup.
|
15
|
-
* Download files changed size or mday from last backup.
|
16
|
-
* backup target are file,symbolic link and directory (not device,socket,pipe)
|
17
|
-
* restore whichever version by specified backup file tree information.
|
18
|
-
* Only Linux or BSD (not windows)
|
19
|
-
|
20
|
-
|
21
|
-
== SYNOPSIS:
|
22
|
-
|
23
|
-
In a nutshell:
|
24
|
-
To use
|
25
|
-
<backups>
|
26
|
-
<backup>
|
27
|
-
<name>backup name</name>
|
28
|
-
<server>server name</server>
|
29
|
-
<user>login name</user>
|
30
|
-
<password>login password</password>
|
31
|
-
<path>path for backup</path>
|
32
|
-
<ignore_list>
|
33
|
-
<ignore>regular expression for not backup </ignore>
|
34
|
-
:
|
35
|
-
</ignore_list>
|
36
|
-
</backup>
|
37
|
-
:
|
38
|
-
</backups>
|
39
|
-
|
40
|
-
/backups
|
41
|
-
mandatory. root directory. It has children of backup informations
|
42
|
-
/backups/backup
|
43
|
-
mandatory. unit of backup information
|
44
|
-
/backups/backup/name
|
45
|
-
mandatory. backup information name
|
46
|
-
/backups/backup/server
|
47
|
-
mandatory. remote host address.
|
48
|
-
/backups/backup/user
|
49
|
-
mandatory. login name to remote host .
|
50
|
-
/backups/backup/password
|
51
|
-
mandatory. login password to remote host .
|
52
|
-
/backups/backup/path
|
53
|
-
mandatory. path for begin to backup on remote host.
|
54
|
-
/backups/backup/ignore_list
|
55
|
-
option. parent of ignore entity.
|
56
|
-
/backups/backup/ignore
|
57
|
-
option. don't wish file or directory name under backup path.
|
58
|
-
|
59
|
-
command:
|
60
|
-
|
61
|
-
remote_backup [-f filename] [-o output_dir] [-v verbos]
|
62
|
-
|
63
|
-
|
64
|
-
filename:
|
65
|
-
file name written backup information. if not specified default is ./backup.xml
|
66
|
-
|
67
|
-
output_dir:
|
68
|
-
repository directory. if not specified default is .(current directory)
|
69
|
-
Backup file is stored and backup file tree information yaml is maked in repository directory
|
70
|
-
+ backup name.
|
71
|
-
|
72
|
-
verbos
|
73
|
-
print progress to stdout
|
74
|
-
|
75
|
-
|
76
|
-
restore_backup -f filename -o output directory [-v verbos]
|
77
|
-
|
78
|
-
|
79
|
-
filename:
|
80
|
-
backup file tree information yaml which locate repository directory + backup name + yyyy_mm_dd_hh_mm.yaml
|
81
|
-
|
82
|
-
output directory:
|
83
|
-
directory you want to make backup tree.
|
84
|
-
|
85
|
-
verbos
|
86
|
-
print progress to stdout
|
87
|
-
|
88
|
-
== REQUIREMENTS:
|
89
|
-
|
90
|
-
* Net::SSH 2
|
91
|
-
* Net::SCP
|
92
|
-
|
93
|
-
== INSTALL:
|
94
|
-
|
95
|
-
* gem install remote-backup (might need sudo privileges)
|
96
|
-
|
97
|
-
Or, you can do it the hard way (without Rubygems):
|
98
|
-
|
99
|
-
* tar xzf net-backup-*.tgz
|
100
|
-
* cd remote-backup-*
|
101
|
-
* ruby setup.rb config
|
102
|
-
* ruby setup.rb install (might need sudo privileges)
|
103
|
-
|
104
|
-
== LICENSE:
|
105
|
-
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
|
106
|
-
You can redistribute it and/or modify it under either the terms of the GPL
|
107
|
-
(see COPYING.txt file), or the conditions below:
|
108
|
-
|
109
|
-
1. You may make and give away verbatim copies of the source form of the
|
110
|
-
software without restriction, provided that you duplicate all of the
|
111
|
-
original copyright notices and associated disclaimers.
|
112
|
-
|
113
|
-
2. You may modify your copy of the software in any way, provided that
|
114
|
-
you do at least ONE of the following:
|
115
|
-
|
116
|
-
a) place your modifications in the Public Domain or otherwise
|
117
|
-
make them Freely Available, such as by posting said
|
118
|
-
modifications to Usenet or an equivalent medium, or by allowing
|
119
|
-
the author to include your modifications in the software.
|
120
|
-
|
121
|
-
b) use the modified software only within your corporation or
|
122
|
-
organization.
|
123
|
-
|
124
|
-
c) rename any non-standard executables so the names do not conflict
|
125
|
-
with standard executables, which must also be provided.
|
126
|
-
|
127
|
-
d) make other distribution arrangements with the author.
|
128
|
-
|
129
|
-
3. You may distribute the software in object code or executable
|
130
|
-
form, provided that you do at least ONE of the following:
|
131
|
-
|
132
|
-
a) distribute the executables and library files of the software,
|
133
|
-
together with instructions (in the manual page or equivalent)
|
134
|
-
on where to get the original distribution.
|
135
|
-
|
136
|
-
b) accompany the distribution with the machine-readable source of
|
137
|
-
the software.
|
138
|
-
|
139
|
-
c) give non-standard executables non-standard names, with
|
140
|
-
instructions on where to get the original software distribution.
|
141
|
-
|
142
|
-
d) make other distribution arrangements with the author.
|
143
|
-
|
144
|
-
4. You may modify and include the part of the software into any other
|
145
|
-
software (possibly commercial). But some files in the distribution
|
146
|
-
are not written by the author, so that they are not under this terms.
|
147
|
-
|
148
|
-
They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
|
149
|
-
files under the ./missing directory. See each file for the copying
|
150
|
-
condition.
|
151
|
-
|
152
|
-
5. The scripts and library files supplied as input to or produced as
|
153
|
-
output from the software do not automatically fall under the
|
154
|
-
copyright of the software, but belong to whomever generated them,
|
155
|
-
and may be sold commercially, and may be aggregated with this
|
156
|
-
software.
|
157
|
-
|
158
|
-
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
159
|
-
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
160
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
161
|
-
PURPOSE.
|
162
|
-
|
1
|
+
= remote_backup
|
2
|
+
|
3
|
+
* http://net-ssh.rubyforge.org/remotebackup
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
remote ssh backup is backup files on remote server with ssh. It's not required any program on remote server.Only download files which changed size or mday. And you can restore not only last version but also past version.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
* Transfer files or entire directory trees from a remote host via SCP
|
11
|
+
* Configurete server,path,user,password and ignore directory or files by xml.
|
12
|
+
* remote_backup makes backup file tree information by yaml named yyyymmdd.yml in repository + backup name
|
13
|
+
* restore_backup read backup file tree information and reconstruct from repository to outputdir.
|
14
|
+
* Make backup file tree information when more than one files are changed on remote server from last backup.
|
15
|
+
* Download files changed size or mday from last backup.
|
16
|
+
* backup target are file,symbolic link and directory (not device,socket,pipe)
|
17
|
+
* restore whichever version by specified backup file tree information.
|
18
|
+
* Only Linux or BSD (not windows)
|
19
|
+
|
20
|
+
|
21
|
+
== SYNOPSIS:
|
22
|
+
|
23
|
+
In a nutshell:
|
24
|
+
To use remotebackup,you should prepare backup configuretion by xml such below.
|
25
|
+
<backups>
|
26
|
+
<backup>
|
27
|
+
<name>backup name</name>
|
28
|
+
<server>server name</server>
|
29
|
+
<user>login name</user>
|
30
|
+
<password>login password</password>
|
31
|
+
<path>path for backup</path>
|
32
|
+
<ignore_list>
|
33
|
+
<ignore>regular expression for not backup </ignore>
|
34
|
+
:
|
35
|
+
</ignore_list>
|
36
|
+
</backup>
|
37
|
+
:
|
38
|
+
</backups>
|
39
|
+
|
40
|
+
/backups
|
41
|
+
mandatory. root directory. It has children of backup informations
|
42
|
+
/backups/backup
|
43
|
+
mandatory. unit of backup information
|
44
|
+
/backups/backup/name
|
45
|
+
mandatory. backup information name
|
46
|
+
/backups/backup/server
|
47
|
+
mandatory. remote host address.
|
48
|
+
/backups/backup/user
|
49
|
+
mandatory. login name to remote host .
|
50
|
+
/backups/backup/password
|
51
|
+
mandatory. login password to remote host .
|
52
|
+
/backups/backup/path
|
53
|
+
mandatory. path for begin to backup on remote host.
|
54
|
+
/backups/backup/ignore_list
|
55
|
+
option. parent of ignore entity.
|
56
|
+
/backups/backup/ignore
|
57
|
+
option. don't wish file or directory name under backup path.
|
58
|
+
|
59
|
+
command:
|
60
|
+
|
61
|
+
remote_backup [-f filename] [-o output_dir] [-v verbos]
|
62
|
+
|
63
|
+
|
64
|
+
filename:
|
65
|
+
file name written backup information. if not specified default is ./backup.xml
|
66
|
+
|
67
|
+
output_dir:
|
68
|
+
repository directory. if not specified default is .(current directory)
|
69
|
+
Backup file is stored and backup file tree information yaml is maked in repository directory
|
70
|
+
+ backup name.
|
71
|
+
|
72
|
+
verbos
|
73
|
+
print progress to stdout
|
74
|
+
|
75
|
+
|
76
|
+
restore_backup -f filename -o output directory [-v verbos]
|
77
|
+
|
78
|
+
|
79
|
+
filename:
|
80
|
+
backup file tree information yaml which locate repository directory + backup name + yyyy_mm_dd_hh_mm.yaml
|
81
|
+
|
82
|
+
output directory:
|
83
|
+
directory you want to make backup tree.
|
84
|
+
|
85
|
+
verbos
|
86
|
+
print progress to stdout
|
87
|
+
|
88
|
+
== REQUIREMENTS:
|
89
|
+
|
90
|
+
* Net::SSH 2
|
91
|
+
* Net::SCP
|
92
|
+
|
93
|
+
== INSTALL:
|
94
|
+
|
95
|
+
* gem install remote-backup (might need sudo privileges)
|
96
|
+
|
97
|
+
Or, you can do it the hard way (without Rubygems):
|
98
|
+
|
99
|
+
* tar xzf net-backup-*.tgz
|
100
|
+
* cd remote-backup-*
|
101
|
+
* ruby setup.rb config
|
102
|
+
* ruby setup.rb install (might need sudo privileges)
|
103
|
+
|
104
|
+
== LICENSE:
|
105
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
|
106
|
+
You can redistribute it and/or modify it under either the terms of the GPL
|
107
|
+
(see COPYING.txt file), or the conditions below:
|
108
|
+
|
109
|
+
1. You may make and give away verbatim copies of the source form of the
|
110
|
+
software without restriction, provided that you duplicate all of the
|
111
|
+
original copyright notices and associated disclaimers.
|
112
|
+
|
113
|
+
2. You may modify your copy of the software in any way, provided that
|
114
|
+
you do at least ONE of the following:
|
115
|
+
|
116
|
+
a) place your modifications in the Public Domain or otherwise
|
117
|
+
make them Freely Available, such as by posting said
|
118
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
119
|
+
the author to include your modifications in the software.
|
120
|
+
|
121
|
+
b) use the modified software only within your corporation or
|
122
|
+
organization.
|
123
|
+
|
124
|
+
c) rename any non-standard executables so the names do not conflict
|
125
|
+
with standard executables, which must also be provided.
|
126
|
+
|
127
|
+
d) make other distribution arrangements with the author.
|
128
|
+
|
129
|
+
3. You may distribute the software in object code or executable
|
130
|
+
form, provided that you do at least ONE of the following:
|
131
|
+
|
132
|
+
a) distribute the executables and library files of the software,
|
133
|
+
together with instructions (in the manual page or equivalent)
|
134
|
+
on where to get the original distribution.
|
135
|
+
|
136
|
+
b) accompany the distribution with the machine-readable source of
|
137
|
+
the software.
|
138
|
+
|
139
|
+
c) give non-standard executables non-standard names, with
|
140
|
+
instructions on where to get the original software distribution.
|
141
|
+
|
142
|
+
d) make other distribution arrangements with the author.
|
143
|
+
|
144
|
+
4. You may modify and include the part of the software into any other
|
145
|
+
software (possibly commercial). But some files in the distribution
|
146
|
+
are not written by the author, so that they are not under this terms.
|
147
|
+
|
148
|
+
They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
|
149
|
+
files under the ./missing directory. See each file for the copying
|
150
|
+
condition.
|
151
|
+
|
152
|
+
5. The scripts and library files supplied as input to or produced as
|
153
|
+
output from the software do not automatically fall under the
|
154
|
+
copyright of the software, but belong to whomever generated them,
|
155
|
+
and may be sold commercially, and may be aggregated with this
|
156
|
+
software.
|
157
|
+
|
158
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
159
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
160
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
161
|
+
PURPOSE.
|
162
|
+
|
data/Rakefile
CHANGED
@@ -1,4 +1,27 @@
|
|
1
|
-
require
|
2
|
-
require '
|
1
|
+
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
2
|
+
require File.dirname(__FILE__) + '/lib/remotebackup'
|
3
3
|
|
4
|
-
|
4
|
+
# Generate all the Rake tasks
|
5
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
|
+
$hoe = Hoe.new('remotebackup', Remotebackup::VERSION) do |p|
|
7
|
+
p.developer('takeshi morita', 'takeshimorita76@gmail.com')
|
8
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
9
|
+
p.rubyforge_name = p.name # TODO this is default value
|
10
|
+
p.extra_deps = [
|
11
|
+
['net-ssh','>= 2.0.4'],
|
12
|
+
['net-scp','>= 1.0.1'],
|
13
|
+
]
|
14
|
+
p.extra_dev_deps = [
|
15
|
+
['newgem', ">= #{::Newgem::VERSION}"]
|
16
|
+
]
|
17
|
+
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
18
|
+
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
19
|
+
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
20
|
+
p.rsync_args = '-av --delete --ignore-errors'
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'newgem/tasks' # load /tasks/*.rake
|
24
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
25
|
+
|
26
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
27
|
+
# task :default => [:spec, :features]
|
data/bin/remote_backup
CHANGED
File without changes
|
data/bin/restore_backup
CHANGED
File without changes
|
data/lib/remotebackup.rb
CHANGED
@@ -10,40 +10,58 @@ require "date"
|
|
10
10
|
require 'logger'
|
11
11
|
require 'yaml'
|
12
12
|
module Remotebackup
|
13
|
+
VERSION='0.50.2'
|
13
14
|
class Node
|
14
15
|
attr_accessor :ftype,:name,:makeMap
|
16
|
+
LS_FILE = /([-a-z]*)\s+(\d+)\s+(\S+)\s+(\S+)\s+(\d*)\s+([A-Z][a-z]*)\s+(\d+)\s+([\d:]*)\s+(.*)/
|
17
|
+
LS_LINK = /([-a-z]*)\s+(\d+)\s+(\S+)\s+(\S+)\s+(\d*)\s+([A-Z][a-z]*)\s+(\d+)\s+([\d:]*)\s+(.*)\s+->\s+(.*)/
|
15
18
|
Result = {:access=>0,:link_num=>1,:user=>2,:group=>3,:size=>4,:month=>5,:day=>6,:yt=>7,:name=>8,:arrow=>9,:source=>10}
|
16
19
|
Month = {"Jan" => 1, "Feb" => 2, "Mar" => 3, "Apr" => 4, "May" => 5, "Jun" => 6, "Jul" => 7, "Aug" => 8,
|
17
20
|
"Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12}
|
21
|
+
|
18
22
|
def initialize(out)
|
19
|
-
|
20
|
-
|
21
|
-
|
23
|
+
@name=""
|
24
|
+
if out !~ /^[[:print:]]*$/
|
25
|
+
$log.error("#{out} includes irregular char. ignore.")
|
26
|
+
end
|
27
|
+
case out
|
22
28
|
when /^-/
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
29
|
+
if LS_FILE.match(out)
|
30
|
+
@name = $9
|
31
|
+
@ftype = :file
|
32
|
+
@size = $5.to_i
|
33
|
+
month = Month[$6]
|
34
|
+
day = $7.to_i
|
35
|
+
hour = 0
|
36
|
+
minute = 0
|
37
|
+
tmpTime = $8
|
38
|
+
if tmpTime =~ /(.*):(.*)/
|
39
|
+
year = DateTime.now.year
|
40
|
+
hour = $1.to_i
|
41
|
+
minute = $2.to_i
|
42
|
+
else
|
43
|
+
year = tmpTime.to_i
|
44
|
+
end
|
45
|
+
@date = DateTime.new(year,month,day,hour,minute).to_s
|
46
|
+
@makeMap = lambda{ return {"size" => @size, "date" => @date}}
|
47
|
+
else
|
48
|
+
$log.error("#{out} is not recognized. ignore.")
|
49
|
+
end
|
38
50
|
when /^l/
|
39
|
-
|
40
|
-
|
41
|
-
|
51
|
+
if LS_LINK.match(out)
|
52
|
+
@name = $9
|
53
|
+
@ftype = :symbolic
|
54
|
+
@source = $10
|
55
|
+
@makeMap = lambda{ return {"source" => @source}}
|
56
|
+
end
|
42
57
|
when /^d/
|
43
|
-
|
58
|
+
if LS_FILE.match(out)
|
59
|
+
@name = $9
|
60
|
+
@ftype = :directory
|
61
|
+
end
|
44
62
|
else
|
45
63
|
@ftype = :special
|
46
|
-
$log.error("#{
|
64
|
+
$log.error("#{out} is not regular file. ignore.")
|
47
65
|
end
|
48
66
|
end
|
49
67
|
end
|
@@ -84,7 +102,7 @@ module Remotebackup
|
|
84
102
|
channel = session.open_channel do |ch|
|
85
103
|
ch.exec cmd do |ch,success|
|
86
104
|
ch.on_data do |c,data|
|
87
|
-
out
|
105
|
+
out += data
|
88
106
|
end
|
89
107
|
end
|
90
108
|
end
|
@@ -98,7 +116,7 @@ module Remotebackup
|
|
98
116
|
end
|
99
117
|
lines = StringIO.new(out).readlines
|
100
118
|
if lines[0].split().length < 9
|
101
|
-
@fileMap["directory"].
|
119
|
+
@fileMap["directory"].push target unless target == ""
|
102
120
|
makeFileMap(session,target,lines)
|
103
121
|
else
|
104
122
|
node = Node.new(lines[0].chomp)
|
@@ -138,14 +156,22 @@ module Remotebackup
|
|
138
156
|
end
|
139
157
|
end
|
140
158
|
end
|
141
|
-
def
|
159
|
+
def outputFileInfo(out_dir)
|
142
160
|
output_dir = out_dir + "/" + @name
|
143
161
|
FileUtils.mkdir_p(output_dir)
|
144
|
-
|
145
|
-
File.open(
|
162
|
+
@outputFile = output_dir + "/" + date_to_filename + ".txt"
|
163
|
+
File.open(@outputFile,"w") do |f|
|
146
164
|
f.write YAML.dump(@fileMap)
|
147
165
|
end
|
148
166
|
end
|
167
|
+
def outputYaml()
|
168
|
+
newFile = @outputFile.sub(/.txt$/,".yml")
|
169
|
+
FileUtils.mv(@outputFile,newFile)
|
170
|
+
end
|
171
|
+
def cleanFileInfo()
|
172
|
+
FileUtils.rm(@outputFile)
|
173
|
+
FileUtils.touch([@last_file])
|
174
|
+
end
|
149
175
|
def load_last_yaml(output_dir)
|
150
176
|
files = Array.new
|
151
177
|
if FileTest.directory?(output_dir)
|
@@ -186,9 +212,11 @@ module Remotebackup
|
|
186
212
|
if !oldFileMap[key] || oldFileMap[key]["size"] != val["size"] || oldFileMap[key]["date"] != val["date"]
|
187
213
|
@mod = true
|
188
214
|
file_name = output_dir + "/" + key + date_to_filename
|
189
|
-
|
215
|
+
orig = "#{@path}/#{key}".gsub(/ /,"\\ ")
|
216
|
+
dest = file_name.gsub(/ /,"\\ ")
|
217
|
+
msg_out "scp #{@user}@#{@server}:#{orig} #{dest} #password=#{@password}"
|
190
218
|
Net::SSH.start(@server, @user, :password => @password) do |ssh|
|
191
|
-
ssh.scp.download!
|
219
|
+
ssh.scp.download!(orig,file_name)
|
192
220
|
end
|
193
221
|
val["file_name"] = file_name
|
194
222
|
if !oldFileMap[key]
|
@@ -228,7 +256,9 @@ module Remotebackup
|
|
228
256
|
if elem.name == "ignore_list"
|
229
257
|
ignores = Array.new
|
230
258
|
elem.each_element do |ignore|
|
231
|
-
|
259
|
+
if ignore.text
|
260
|
+
ignores.push(ignore.text)
|
261
|
+
end
|
232
262
|
end
|
233
263
|
bkup_info["ignore_list"] = ignores
|
234
264
|
else
|
@@ -245,11 +275,12 @@ module Remotebackup
|
|
245
275
|
msg_out "--------------------------------"
|
246
276
|
msg_out "Backup start #{conf['name']}"
|
247
277
|
msg_out "--------------------------------"
|
278
|
+
bkup.outputFileInfo(@config_out_dir)
|
248
279
|
bkup.differencial_copy(@config_out_dir)
|
249
280
|
if bkup.mod
|
250
|
-
|
281
|
+
bkup.outputYaml()
|
251
282
|
else
|
252
|
-
|
283
|
+
bkup.cleanFileInfo()
|
253
284
|
end
|
254
285
|
end
|
255
286
|
end
|
data/script/console
CHANGED
File without changes
|
data/script/destroy
CHANGED
File without changes
|
data/script/generate
CHANGED
File without changes
|
data/test/test_helper.rb
CHANGED