remotebackup 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2008-06-23
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 FIXME full name
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,27 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ PostInstall.txt
5
+ README.txt
6
+ Rakefile
7
+ config/hoe.rb
8
+ config/requirements.rb
9
+ lib/remotebackup.rb
10
+ lib/remotebackup/version.rb
11
+ bin/remote_backup
12
+ bin/restore_backup
13
+ script/console
14
+ script/destroy
15
+ script/generate
16
+ script/txt2html
17
+ setup.rb
18
+ tasks/deployment.rake
19
+ tasks/environment.rake
20
+ tasks/website.rake
21
+ test/test_helper.rb
22
+ 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/PostInstall.txt ADDED
@@ -0,0 +1,7 @@
1
+
2
+ For more information on remotebackup, see http://remotebackup.rubyforge.org
3
+
4
+ NOTE: Change this information in PostInstall.txt
5
+ You can also delete it if you don't want it.
6
+
7
+
data/README.txt ADDED
@@ -0,0 +1,149 @@
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 remote_backup,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>user name</user>
30
+ <password>user name</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
+ remote_backup [-f filename] [-o output repository directory]
61
+
62
+ filename:
63
+ file name written backup information. if not specified default is ./backup.xml
64
+ output directory:
65
+ repository directory. if not specified default is .(current directory)
66
+ Backup file is stored and backup file tree information yaml is maked in repository directory
67
+ + backup name.
68
+
69
+ restore_backup -f filename -o output directory
70
+ filename:
71
+ backup file tree information yaml which locate repository directory + backup name + yyyymmdd.yaml
72
+ output directory:
73
+ directory you want to make backup tree.
74
+
75
+ == REQUIREMENTS:
76
+
77
+ * Net::SSH 2
78
+ * Net::SCP
79
+
80
+ == INSTALL:
81
+
82
+ * gem install remote-backup (might need sudo privileges)
83
+
84
+ Or, you can do it the hard way (without Rubygems):
85
+
86
+ * tar xzf net-backup-*.tgz
87
+ * cd remote-backup-*
88
+ * ruby setup.rb config
89
+ * ruby setup.rb install (might need sudo privileges)
90
+
91
+ == LICENSE:
92
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
93
+ You can redistribute it and/or modify it under either the terms of the GPL
94
+ (see COPYING.txt file), or the conditions below:
95
+
96
+ 1. You may make and give away verbatim copies of the source form of the
97
+ software without restriction, provided that you duplicate all of the
98
+ original copyright notices and associated disclaimers.
99
+
100
+ 2. You may modify your copy of the software in any way, provided that
101
+ you do at least ONE of the following:
102
+
103
+ a) place your modifications in the Public Domain or otherwise
104
+ make them Freely Available, such as by posting said
105
+ modifications to Usenet or an equivalent medium, or by allowing
106
+ the author to include your modifications in the software.
107
+
108
+ b) use the modified software only within your corporation or
109
+ organization.
110
+
111
+ c) rename any non-standard executables so the names do not conflict
112
+ with standard executables, which must also be provided.
113
+
114
+ d) make other distribution arrangements with the author.
115
+
116
+ 3. You may distribute the software in object code or executable
117
+ form, provided that you do at least ONE of the following:
118
+
119
+ a) distribute the executables and library files of the software,
120
+ together with instructions (in the manual page or equivalent)
121
+ on where to get the original distribution.
122
+
123
+ b) accompany the distribution with the machine-readable source of
124
+ the software.
125
+
126
+ c) give non-standard executables non-standard names, with
127
+ instructions on where to get the original software distribution.
128
+
129
+ d) make other distribution arrangements with the author.
130
+
131
+ 4. You may modify and include the part of the software into any other
132
+ software (possibly commercial). But some files in the distribution
133
+ are not written by the author, so that they are not under this terms.
134
+
135
+ They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
136
+ files under the ./missing directory. See each file for the copying
137
+ condition.
138
+
139
+ 5. The scripts and library files supplied as input to or produced as
140
+ output from the software do not automatically fall under the
141
+ copyright of the software, but belong to whomever generated them,
142
+ and may be sold commercially, and may be aggregated with this
143
+ software.
144
+
145
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
146
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
147
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
148
+ PURPOSE.
149
+
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
data/bin/remote_backup ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require "optparse"
4
+ require 'logger'
5
+ require 'remotebackup'
6
+
7
+ $log = Logger.new(File.open("backup_error.log","w"))
8
+ def msg_out(str)
9
+ if $verbose
10
+ puts str
11
+ end
12
+ end
13
+ def opt_parse()
14
+ begin
15
+ parser = OptionParser.new do |opt|
16
+ opt.banner = "Usage: #{File.basename($0)} [Option]"
17
+ opt.on("-f","--file config",String,'location config file. default ./backup.xml') {|o|
18
+ $config_file = o
19
+ }
20
+ opt.on("-o","--outputdir Output Directory",String,"Directory for output. Default #{ENV['HOME']}") {|o|
21
+ $config_out_dir = o
22
+ }
23
+ opt.on("-v","--verbose","verbose message"){
24
+ $verbose = true
25
+ }
26
+ opt.on("-h","--help","print this message and quit") {|o|
27
+ puts opt.help
28
+ exit 0
29
+ }
30
+ opt.parse!(ARGV)
31
+ end
32
+ rescue OptionParser::ParseError => err
33
+ $stderr.puts err.message
34
+ exit 1
35
+ end
36
+ unless $config_file
37
+ $config_file = "./backup.xml"
38
+ end
39
+ unless $config_out_dir
40
+ $config_out_dir = "."
41
+ end
42
+ if !File.file?($config_file)
43
+ $stderr.puts "config #{$config_file} is not exist."
44
+ $stderr.puts parser.help
45
+ exit 1
46
+ end
47
+ if !FileTest.directory?($config_out_dir)
48
+ $stderr.puts "output directory #{$config_out_dir} is not directory."
49
+ $stderr.puts parser.help
50
+ exit 1
51
+ end
52
+ end
53
+ opt_parse
54
+ bk=Remotebackup::Backup.new($config_file,$config_out_dir)
55
+ bk.start
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require "optparse"
4
+ require 'logger'
5
+ require 'remotebackup'
6
+
7
+ $log = log = Logger.new(File.open("restore_error.log","w"))
8
+ def msg_out(str)
9
+ if $verbose
10
+ puts str
11
+ end
12
+ end
13
+ def opt_parse()
14
+ begin
15
+ parser = OptionParser.new do |opt|
16
+ opt.banner = "Usage: #{File.basename($0)} [Option]"
17
+ opt.on("-f","--file info",String,'file info yaml.') {|o|
18
+ $config_file = o
19
+ }
20
+ opt.on("-o","--outputdir output_directory",String,"Directory for output.") {|o|
21
+ $config_out_dir = o
22
+ }
23
+ opt.on("-v","--verbose","verbose message"){
24
+ $verbose = true
25
+ }
26
+ opt.on("-h","--help","print this message and quit") {|o|
27
+ puts opt.help
28
+ exit 0
29
+ }
30
+ opt.parse!(ARGV)
31
+ end
32
+ rescue OptionParser::ParseError => err
33
+ $stderr.puts err.message
34
+ exit 1
35
+ end
36
+ unless $config_file
37
+ $stderr.puts "Error:You shoud specified file info yml file with -f."
38
+ $stderr.puts parser.help
39
+ exit 1
40
+ end
41
+ unless $config_out_dir
42
+ $stderr.puts "Error:You shoud specified output dir with -o."
43
+ $stderr.puts parser.help
44
+ exit 1
45
+ end
46
+ if !File.file?($config_file)
47
+ $stderr.puts "Error:file info yaml #{$config_file} is not exist."
48
+ $stderr.puts parser.help
49
+ exit 1
50
+ end
51
+ if FileTest.directory?($config_out_dir)
52
+ $stderr.puts "Error:output directory #{$config_out_dir} is already exist."
53
+ $stderr.puts parser.help
54
+ exit 1
55
+ end
56
+ end
57
+ opt_parse
58
+ rs=RemoteBackup::Restore.new($config_file,$config_out_dir)
59
+ rs.start
data/config/hoe.rb ADDED
@@ -0,0 +1,73 @@
1
+ require 'remotebackup/version'
2
+
3
+ AUTHOR = 'FIXME full name' # can also be an array of Authors
4
+ EMAIL = "FIXME email"
5
+ DESCRIPTION = "description of gem"
6
+ GEM_NAME = 'remotebackup' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'remotebackup' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+ EXTRA_DEPENDENCIES = [
11
+ # ['activesupport', '>= 1.3.1']
12
+ ] # An array of rubygem dependencies [name, version]
13
+
14
+ @config_file = "~/.rubyforge/user-config.yml"
15
+ @config = nil
16
+ RUBYFORGE_USERNAME = "unknown"
17
+ def rubyforge_username
18
+ unless @config
19
+ begin
20
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
21
+ rescue
22
+ puts <<-EOS
23
+ ERROR: No rubyforge config file found: #{@config_file}
24
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
25
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
26
+ EOS
27
+ exit
28
+ end
29
+ end
30
+ RUBYFORGE_USERNAME.replace @config["username"]
31
+ end
32
+
33
+
34
+ REV = nil
35
+ # UNCOMMENT IF REQUIRED:
36
+ # REV = YAML.load(`svn info`)['Revision']
37
+ VERS = Remotebackup::VERSION::STRING + (REV ? ".#{REV}" : "")
38
+ RDOC_OPTS = ['--quiet', '--title', 'remotebackup documentation',
39
+ "--opname", "index.html",
40
+ "--line-numbers",
41
+ "--main", "README",
42
+ "--inline-source"]
43
+
44
+ class Hoe
45
+ def extra_deps
46
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
47
+ @extra_deps
48
+ end
49
+ end
50
+
51
+ # Generate all the Rake tasks
52
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
53
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
54
+ p.developer(AUTHOR, EMAIL)
55
+ p.description = DESCRIPTION
56
+ p.summary = DESCRIPTION
57
+ p.url = HOMEPATH
58
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
59
+ p.test_globs = ["test/**/test_*.rb"]
60
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
61
+
62
+ # == Optional
63
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
64
+ #p.extra_deps = EXTRA_DEPENDENCIES
65
+
66
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
67
+ end
68
+
69
+ CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
70
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
71
+ $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
72
+ $hoe.rsync_args = '-av --delete --ignore-errors'
73
+ $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen net/ssh net/scp].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
@@ -0,0 +1,9 @@
1
+ module Remotebackup
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 5
5
+ TINY = 0
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end