syc-backup 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +22 -6
- data/lib/backup/options.rb +3 -5
- data/lib/backup/process.rb +1 -4
- data/lib/backup_version.rb +1 -1
- data/{syc-backup-0.0.4.gem → syc-backup-0.0.5.gem} +0 -0
- data/test/test_options.rb +6 -8
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -7,22 +7,35 @@ The application can be installed with
|
|
7
7
|
|
8
8
|
== Usage
|
9
9
|
Backup a database to the default folder _~/backup_
|
10
|
-
$
|
10
|
+
$ sycbackup -d database -uuser -ppass
|
11
11
|
|
12
12
|
Backup a MySQL database, a directory and files to the default folder
|
13
|
-
$
|
13
|
+
$ sycbackup -d database -uuser -ppass -f directory,file1,file2
|
14
14
|
|
15
15
|
Specify a backup folder
|
16
|
-
$
|
16
|
+
$ sycbackup backup/folder -d database -uuser -ppass -f directory,file1,file2
|
17
17
|
|
18
18
|
Override files in the backup folder if they exist
|
19
|
-
$
|
19
|
+
$ sycbackup backup/folder --override -f directory,file1,file2
|
20
20
|
|
21
21
|
Don't compress the backup
|
22
|
-
$
|
22
|
+
$ sycbackup --no-compress -f directory,file1,file2
|
23
23
|
|
24
24
|
Create a cron job that is scheduled every day at 2:30
|
25
|
-
$
|
25
|
+
$ sycbackup -d database -uuser -ppass -f directory,file1 --cron 30,2,*,*,*
|
26
|
+
|
27
|
+
If the user or password contains characters as '(' you have to escape
|
28
|
+
them. A password like 123(56 has to be provided with pass\"123\\\\(56\".
|
29
|
+
|
30
|
+
== Usage of --override and --no-compress
|
31
|
+
Whether the backup directory and the backup files are time stamped depends how
|
32
|
+
--override and --no-compress is set. The results are shown in the table below.
|
33
|
+
|
34
|
+
--override --no-compress backup directory backup file(s)
|
35
|
+
0 0 w/o timestamp w/ timestamp
|
36
|
+
1 0 w/o timestamp w/ timestamp
|
37
|
+
0 1 w/ timestamp uncompressed
|
38
|
+
1 1 w/o timestamp uncompressed
|
26
39
|
|
27
40
|
== Supported Platform
|
28
41
|
syc-backup has been tested with 1.9.3
|
@@ -41,6 +54,9 @@ The tests create folders and files and will be deleted after the tests finish. _
|
|
41
54
|
|
42
55
|
The test files live in the test folder and begin with test_.
|
43
56
|
|
57
|
+
There is a rake file available which can be used to run all tests with
|
58
|
+
$ rake test
|
59
|
+
|
44
60
|
== Links
|
45
61
|
* [http://sugaryourcoffee.github.com/syc-backup] - RubyDoc
|
46
62
|
* [http://www.github.com/sugaryourcoffee/syc-backup] - Source code on GitHub
|
data/lib/backup/options.rb
CHANGED
@@ -101,12 +101,10 @@ module Backup
|
|
101
101
|
# provided by the user
|
102
102
|
def initialize_default_arguments_if_missing
|
103
103
|
@backup_folder = DEFAULT_BACKUP_FOLDER unless @backup_folder
|
104
|
-
|
104
|
+
if @override and @no_compress
|
105
105
|
timestamp = Time.now.strftime("%Y%m%d-%H%M%S")
|
106
|
-
|
107
|
-
|
108
|
-
File.basename(@backup_folder) + '_' + timestamp
|
109
|
-
end
|
106
|
+
@backup_folder = File.dirname(@backup_folder) + '/' +
|
107
|
+
File.basename(@backup_folder) + '_' + timestamp
|
110
108
|
end
|
111
109
|
@backup_folder = File.expand_path(@backup_folder)
|
112
110
|
@backup_folder += '/' unless @backup_folder.match(/.*\/\Z/)
|
data/lib/backup/process.rb
CHANGED
@@ -74,10 +74,7 @@ module Backup
|
|
74
74
|
# displayed and the application exits. If the method runs without errors
|
75
75
|
# the tar file is returned
|
76
76
|
def compress_files_and_copy
|
77
|
-
timestamp = ""
|
78
|
-
unless @override
|
79
|
-
timestamp = Time.now.strftime("%Y%m%d-%H%M%S") + '_'
|
80
|
-
end
|
77
|
+
timestamp = Time.now.strftime("%Y%m%d-%H%M%S") + '_'
|
81
78
|
tar_file = @backup_folder + timestamp + "syc-backup.tar.gz"
|
82
79
|
tar_command = "tar cfz #{tar_file} #{@files.join(" ")}"
|
83
80
|
|
data/lib/backup_version.rb
CHANGED
Binary file
|
data/test/test_options.rb
CHANGED
@@ -102,18 +102,11 @@ class TestOptions < Test::Unit::TestCase
|
|
102
102
|
context "Correct user input" do
|
103
103
|
|
104
104
|
should "return database, user, password and default backup_folder" do
|
105
|
-
default_backup_folder_exists =
|
106
|
-
File.exists? Backup::Options::DEFAULT_BACKUP_FOLDER
|
107
105
|
opts = Backup::Options.new(["-d", "database", "-u", "user", "-p", "pass"])
|
108
106
|
assert_equal "database", opts.database
|
109
107
|
assert_equal "user", opts.user
|
110
108
|
assert_equal "pass", opts.password
|
111
|
-
|
112
|
-
assert_match Backup::Options::DEFAULT_BACKUP_FOLDER, opts.backup_folder
|
113
|
-
else
|
114
|
-
assert_match /#{Backup::Options::DEFAULT_BACKUP_FOLDER}_\d{8}-\d{6}\//,
|
115
|
-
opts.backup_folder
|
116
|
-
end
|
109
|
+
assert_match Backup::Options::DEFAULT_BACKUP_FOLDER, opts.backup_folder
|
117
110
|
end
|
118
111
|
|
119
112
|
should "return database and specified backup folder" do
|
@@ -184,6 +177,11 @@ class TestOptions < Test::Unit::TestCase
|
|
184
177
|
assert_equal true, opts.no_compress
|
185
178
|
end
|
186
179
|
|
180
|
+
should "return time stamped backup directory" do
|
181
|
+
opts = Backup::Options.new(["-f", "a,b,c", "--no-compress", "--override"])
|
182
|
+
assert_match /#{Backup::Options::DEFAULT_BACKUP_FOLDER}_\d{8}-\d{6}\//,
|
183
|
+
opts.backup_folder
|
184
|
+
end
|
187
185
|
end
|
188
186
|
|
189
187
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syc-backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-04 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! "Back up a database and files or schedule cron job \n for
|
15
15
|
backup"
|
@@ -19,6 +19,7 @@ executables:
|
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
+
- syc-backup-0.0.5.gem
|
22
23
|
- README.rdoc
|
23
24
|
- test/test_process.rb
|
24
25
|
- test/test_mysql_backup.rb
|
@@ -26,7 +27,6 @@ files:
|
|
26
27
|
- test/test_cron_edit.rb
|
27
28
|
- test/test_environment.rb
|
28
29
|
- test/test_file_backup.rb
|
29
|
-
- syc-backup-0.0.4.gem
|
30
30
|
- sycbackup.gemspec
|
31
31
|
- lib/backup_version.rb
|
32
32
|
- lib/backup/file_backup.rb
|