jbackup_rails 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +12 -19
- data/README.md +7 -2
- data/lib/jbackup_rails.rb +1 -1
- data/lib/jbackup_rails/railtie.rb +12 -0
- data/lib/jbackup_rails/version.rb +1 -1
- data/lib/tasks/jbackup_rails.rake +22 -0
- metadata +3 -1
data/LICENSE
CHANGED
@@ -1,22 +1,15 @@
|
|
1
|
-
|
1
|
+
This library help you backup database (currently mysql) and paperclip data which are store in public/system directory
|
2
|
+
Copyright (C) 2012 Naqsh Jahan Toos CO.
|
2
3
|
|
3
|
-
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
5
|
+
it under the terms of the GNU General Public License as published by
|
6
|
+
the Free Software Foundation, either version 3 of the License, or
|
7
|
+
(at your option) any later version.
|
4
8
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
9
|
+
This program is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
GNU General Public License for more details.
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
14
|
+
You should have received a copy of the GNU General Public License
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# JbackupRails
|
2
2
|
|
3
|
-
|
3
|
+
This lib help you backup database (currently is just mysql) and paperclip data files which store in public/system directory.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,12 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
You can backup database by this rake command:
|
22
|
+
* rake db:backup RAILS_ENV=production
|
23
|
+
|
24
|
+
By defining environment, you can tell it which database you want.
|
25
|
+
|
26
|
+
** Note: backups saved in $HOME/dbs directory.
|
22
27
|
|
23
28
|
## Contributing
|
24
29
|
|
data/lib/jbackup_rails.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
namespace :db do
|
2
|
+
desc "backup mysql database and paperclip data and save it in ~/dbs"
|
3
|
+
task :backup => :environment do
|
4
|
+
CONFIG = Rails.configuration.database_configuration
|
5
|
+
DB = CONFIG[Rails.env]["database"]
|
6
|
+
USER = CONFIG[Rails.env]["username"]
|
7
|
+
PW = CONFIG[Rails.env]["password"]
|
8
|
+
|
9
|
+
today_s = Date.today().to_s
|
10
|
+
|
11
|
+
TODAY_BACKUP = "#{ENV["HOME"]}/dbs/#{today_s}-#{DB}.sql"
|
12
|
+
|
13
|
+
directory_name = "#{ENV['HOME']}/dbs"
|
14
|
+
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
15
|
+
|
16
|
+
system "/usr/bin/mysqldump --user=#{USER} --password=#{PW} #{DB} > ~/dbs/#{today_s}-#{DB}.sql"
|
17
|
+
if File.exist? "#{Rails.root}/public/system"
|
18
|
+
system "/bin/tar zcfv ~/dbs/#{today_s}-#{DB}.tgz #{TODAY_BACKUP} #{Rails.root}/public/system"
|
19
|
+
File.unlink(TODAY_BACKUP)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jbackup_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -26,7 +26,9 @@ files:
|
|
26
26
|
- Rakefile
|
27
27
|
- jbackup_rails.gemspec
|
28
28
|
- lib/jbackup_rails.rb
|
29
|
+
- lib/jbackup_rails/railtie.rb
|
29
30
|
- lib/jbackup_rails/version.rb
|
31
|
+
- lib/tasks/jbackup_rails.rake
|
30
32
|
homepage: ''
|
31
33
|
licenses: []
|
32
34
|
post_install_message:
|