backupit 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +55 -0
- data/VERSION +1 -1
- data/backupit.gemspec +4 -6
- data/bin/backup +7 -3
- data/lib/backup/storage.rb +4 -4
- data/lib/backup.rb +2 -0
- metadata +5 -7
- data/README +0 -24
- data/README.rdoc +0 -17
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# BackupIt
|
2
|
+
|
3
|
+
## Install
|
4
|
+
$ gem install backupit
|
5
|
+
|
6
|
+
## Configuration File Example
|
7
|
+
|
8
|
+
storage :file do
|
9
|
+
path '/opt/backup/'
|
10
|
+
end
|
11
|
+
|
12
|
+
server 'delonghi' do
|
13
|
+
host "delonghi@10.0.1.1"
|
14
|
+
port "222"
|
15
|
+
|
16
|
+
rsync ['/home/www/app/shared/config',{'/home/staging/app/shared/config' => 'staging_config'}, '/home/www/app/shared/attachments']
|
17
|
+
|
18
|
+
mysql 'delonghi' do
|
19
|
+
user 'root'
|
20
|
+
password 'mypassword'
|
21
|
+
options '-h 192.168.1.100'
|
22
|
+
databases ['delonghi-staging', 'delonghi-production']
|
23
|
+
tables ['users','products'] # this would overwrite databases! `man mysqldump` for more help.
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
server 'onitsukatiger' do
|
28
|
+
host "otiger2@192.168.1.4"
|
29
|
+
|
30
|
+
mysql 'ot_staging' do
|
31
|
+
user 'root'
|
32
|
+
password 'mytopsecret'
|
33
|
+
databases 'ot_staging'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
## Usage
|
38
|
+
1, backup --pretend -f /opt/backup/backup.rb delonghi
|
39
|
+
only backup server 'delonghi' (pretend to run)
|
40
|
+
2, backup -f /opt/backup/backup.rb
|
41
|
+
backup all servers
|
42
|
+
|
43
|
+
## Note on Patches/Pull Requests
|
44
|
+
|
45
|
+
* Fork the project.
|
46
|
+
* Make your feature addition or bug fix.
|
47
|
+
* Add tests for it. This is important so I don't break it in a
|
48
|
+
future version unintentionally.
|
49
|
+
* Commit, do not mess with rakefile, version, or history.
|
50
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
51
|
+
* Send me a pull request. Bonus points for topic branches.
|
52
|
+
|
53
|
+
## Copyright
|
54
|
+
|
55
|
+
Copyright (c) 2010 Jinzhu. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/backupit.gemspec
CHANGED
@@ -5,26 +5,24 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{backupit}
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jinzhu"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-27}
|
13
13
|
s.default_executable = %q{backup}
|
14
14
|
s.description = %q{A tool to backup your servers}
|
15
15
|
s.email = %q{wosmvp@gmail.com}
|
16
16
|
s.executables = ["backup"]
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE",
|
19
|
-
"README"
|
20
|
-
"README.rdoc"
|
19
|
+
"README.md"
|
21
20
|
]
|
22
21
|
s.files = [
|
23
22
|
".document",
|
24
23
|
".gitignore",
|
25
24
|
"LICENSE",
|
26
|
-
"README",
|
27
|
-
"README.rdoc",
|
25
|
+
"README.md",
|
28
26
|
"Rakefile",
|
29
27
|
"VERSION",
|
30
28
|
"backupit.gemspec",
|
data/bin/backup
CHANGED
@@ -8,14 +8,16 @@ rescue LoadError
|
|
8
8
|
end
|
9
9
|
|
10
10
|
require 'optparse'
|
11
|
-
require 'backup'
|
11
|
+
require 'lib/backup'
|
12
12
|
|
13
13
|
options = {}
|
14
14
|
|
15
15
|
OptionParser.new do |opts|
|
16
|
-
opts.banner = "Usage: backup --pretend -f config_file
|
16
|
+
opts.banner = "Usage: backup --pretend -f config_file server1 server2
|
17
|
+
default config file: ./backup.rb or ./config/backup.rb
|
18
|
+
default backup all servers\n\n"
|
17
19
|
|
18
|
-
opts.on( '-f', '--file file', '
|
20
|
+
opts.on( '-f', '--file file', 'Configuration file' ) do |file|
|
19
21
|
options[:config] = file
|
20
22
|
end
|
21
23
|
|
@@ -30,6 +32,8 @@ OptionParser.new do |opts|
|
|
30
32
|
opts.parse!
|
31
33
|
end
|
32
34
|
|
35
|
+
options[:name] = ARGV
|
36
|
+
|
33
37
|
if !options[:config] && File.exist?('backup.rb')
|
34
38
|
options[:config] = 'backup.rb'
|
35
39
|
elsif !options[:config] && File.exist?('config/backup.rb')
|
data/lib/backup/storage.rb
CHANGED
@@ -15,10 +15,10 @@ module Backup
|
|
15
15
|
@server_config = @server.config
|
16
16
|
@backup_path = "#{config.path}/#{@server.name}"
|
17
17
|
|
18
|
-
|
19
|
-
@scp_host
|
20
|
-
@rsync_host
|
21
|
-
@ssh_host
|
18
|
+
host = "'#{@server_config.host}'"
|
19
|
+
@scp_host = @server_config.port ? "-P#{@server_config.port} #{host}" : host
|
20
|
+
@rsync_host = @server_config.port ? " -e 'ssh -p#{@server_config.port}' #{host}" : host
|
21
|
+
@ssh_host = "'-p#{@server_config.port}' #{host}" if @server_config.port
|
22
22
|
|
23
23
|
backup_rsync
|
24
24
|
backup_mysql
|
data/lib/backup.rb
CHANGED
@@ -14,6 +14,8 @@ module Backup
|
|
14
14
|
|
15
15
|
@configuration.storage.map do |storage_key, storage_value|
|
16
16
|
@configuration.server.map do |name, config|
|
17
|
+
next if options[:name].size > 0 && options[:name].select {|n| n == name }.size == 0
|
18
|
+
|
17
19
|
server = Backup::Server.new
|
18
20
|
server.name = name
|
19
21
|
server.config = config
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.2
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jinzhu
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-27 00:00:00 +08:00
|
19
19
|
default_executable: backup
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -27,14 +27,12 @@ extensions: []
|
|
27
27
|
|
28
28
|
extra_rdoc_files:
|
29
29
|
- LICENSE
|
30
|
-
- README
|
31
|
-
- README.rdoc
|
30
|
+
- README.md
|
32
31
|
files:
|
33
32
|
- .document
|
34
33
|
- .gitignore
|
35
34
|
- LICENSE
|
36
|
-
- README
|
37
|
-
- README.rdoc
|
35
|
+
- README.md
|
38
36
|
- Rakefile
|
39
37
|
- VERSION
|
40
38
|
- backupit.gemspec
|
data/README
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
= BackUpIt
|
2
|
-
|
3
|
-
== Configuration File Example
|
4
|
-
storage :file do
|
5
|
-
path '/your_backup_path'
|
6
|
-
end
|
7
|
-
|
8
|
-
server 'delonghi' do
|
9
|
-
host "delonghi@10.0.1.1"
|
10
|
-
port "222"
|
11
|
-
|
12
|
-
rsync ['/home/www/app/shared/config',{'/home/staging/app/shared/config' => 'staging_config'}, '/home/www/app/shared/attachments']
|
13
|
-
|
14
|
-
mysql 'delonghi' do
|
15
|
-
user 'root'
|
16
|
-
password 'mypassword'
|
17
|
-
options '-h 192.168.1.100'
|
18
|
-
databases ['delonghi-staging', 'delonghi-production']
|
19
|
-
tables ['users','products'] # this would overwrite databases! `man mysqldump` for more help.
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
== Copyright (c) 2010 Jinzhu. See LICENSE for details.
|
data/README.rdoc
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
= backupit
|
2
|
-
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
== Note on Patches/Pull Requests
|
6
|
-
|
7
|
-
* Fork the project.
|
8
|
-
* Make your feature addition or bug fix.
|
9
|
-
* Add tests for it. This is important so I don't break it in a
|
10
|
-
future version unintentionally.
|
11
|
-
* Commit, do not mess with rakefile, version, or history.
|
12
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
-
* Send me a pull request. Bonus points for topic branches.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2010 Jinzhu. See LICENSE for details.
|