dreamback 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Dreamback is the easiest way to automate your backups on dreamhost. Dreamhost does not guarantee their backups of your users (though they've saved me with backups before), so it's best to run backups yourself.
4
4
 
5
+ ## This is alpha quality software. Please report issues if you have them.
6
+
5
7
  Using Dreamback is easy:
6
8
 
7
9
  1. Create a user on dreamhost to schedule your backups
data/bin/dreamback CHANGED
@@ -1,3 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # Set environment if these paths exist
4
+ gems = File.expand_path("/etc/profile")
5
+ if File.exists?(gems)
6
+ `. /etc/profile`
7
+ end
8
+
3
9
  require 'dreamback'
@@ -76,23 +76,26 @@ module Dreamback
76
76
  # Sync to the backup server using link-dest to save space
77
77
  # @param [String] name of the most recent backup folder prior to starting this run to link against
78
78
  def self.rsync_backup(link_dir)
79
- backup_server_user = Dreamback.settings[:backup_server_user]
80
- backup_server = Dreamback.settings[:backup_server]
81
- today = Time.now.strftime("%Y%m%d")
82
- Dreamback.settings[:dreamhost_users].each do |dreamhost|
83
- # User that we're going to back up
84
- user = dreamhost[:user]
85
- server = dreamhost[:server]
86
- # rsync won't do remote<->remote syncing, so we stage everything here first
87
- tmp_dir = File.expand_path("~/.dreamback_tmp")
88
- Dir.mkdir(tmp_dir) unless File.exists?(tmp_dir)
89
- `rsync -e ssh -av --keep-dirlinks --copy-links #{user}@#{server}:~/ #{tmp_dir}/#{user}@#{server}`
90
- # Now we can sync local to remote
91
- # Only use link-dest if a previous folder to link to exists
92
- link_dest = link_dir.nil? ? "" : "--link-dest=~#{BACKUP_FOLDER.gsub(".", "")}/#{link_dir}"
93
- `rsync -e ssh -av --delete --copy-links --keep-dirlinks #{link_dest} #{tmp_dir}/ #{backup_server_user}@#{backup_server}:#{BACKUP_FOLDER}/dreamback.#{today}`
79
+ tmp_dir_path = "~/.dreamback_tmp"
80
+ begin
81
+ backup_server_user = Dreamback.settings[:backup_server_user]
82
+ backup_server = Dreamback.settings[:backup_server]
83
+ today = Time.now.strftime("%Y%m%d")
84
+ Dreamback.settings[:dreamhost_users].each do |dreamhost|
85
+ # User that we're going to back up
86
+ user = dreamhost[:user]
87
+ server = dreamhost[:server]
88
+ # rsync won't do remote<->remote syncing, so we stage everything here first
89
+ tmp_dir = File.expand_path(tmp_dir_path)
90
+ Dir.mkdir(tmp_dir) unless File.exists?(tmp_dir)
91
+ `rsync -e ssh -av --keep-dirlinks --copy-links #{user}@#{server}:~/ #{tmp_dir}/#{user}@#{server}`
92
+ # Now we can sync local to remote. Only use link-dest if a previous folder to link to exists.
93
+ link_dest = link_dir.nil? ? "" : "--link-dest=~#{BACKUP_FOLDER.gsub(".", "")}/#{link_dir}"
94
+ `rsync -e ssh -av --delete --copy-links --keep-dirlinks #{link_dest} #{tmp_dir}/ #{backup_server_user}@#{backup_server}:#{BACKUP_FOLDER}/dreamback.#{today}`
95
+ end
96
+ ensure
94
97
  # Remove the staging directory
95
- `rm -rf #{tmp_dir}`
98
+ `rm -rf #{File.expand_path(tmp_dir_path)}`
96
99
  end
97
100
  end
98
101
  end
@@ -1,3 +1,3 @@
1
1
  module Dreamback
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dreamback
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paul R Alexander
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-22 00:00:00 -07:00
18
+ date: 2012-05-23 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency