Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added collecting anything sent to stderr from rsync or the snapshot and

including it in the email.
  • Loading branch information...
commit 0a93288ee092adb5c382e0384854a0b29619d539 1 parent b921970
James authored
4 libs/rbrsyncwrapper.rb
View
@@ -39,13 +39,13 @@ def create_email(params)
# params = :name (send_to_name), :address (send_to_address), :rsync_result,
# :email_server (email_server), :sender_name (send_from_name),
# :sender_address (send_from_address), :backup_start_time
- # :snapshot_result
+ # :snapshot_result, :rsync_error, :snapshot_error
email_subject = 'Disk-to-disk backup results'
email_template = File.read(EMAIL_TEMPLATE_LOCATION)
email_eruby = Erubis::FastEruby.new(email_template)
- erb_binding = { :rsync_result => params[:rsync_result], :snapshot_result => params[:snapshot_result], :backup_time => determine_time(params[:backup_start_time]) }
+ erb_binding = { :rsync_result => params[:rsync_result], :snapshot_result => params[:snapshot_result], :backup_time => determine_time(params[:backup_start_time]), :rsync_error => params[:rsync_error], :snapshot_error => params[:snapshot_error]}
email_markdown = Markdown.new(email_eruby.result(erb_binding))
# return this object
14 rbRsyncWrapper.rb
View
@@ -37,10 +37,9 @@
/mnt/btr_pool/files_share_backup/ \
--sockopts=SO_SNDBUF=4194304,SO_RCVBUF=4194304"
-stdin, rsync_result, stderr = Open3.popen3(rsync_command)
-rsync_result = rsync_result.read.split.join(" \n")
-
-puts rsync_result
+stdin, rsync_result, rsync_error = Open3.popen3(rsync_command)
+rsync_result = rsync_result.read.split($/).join(" #{$/}")
+rsync_error = rsync_error.read
# do the snapshot
@@ -48,10 +47,9 @@
/mnt/btr_pool/files_share_backup /mnt/btr_pool/\
files_share_backup-snap-#{backup_start.strftime("%Y.%m.%d-%H.%M.%S")}"
-stdin, snapshot_result, stderr = Open3.popen3(snapshot_command)
+stdin, snapshot_result, snapshot_error = Open3.popen3(snapshot_command)
snapshot_result = snapshot_result.read
-
-puts snapshot_result
+snapshot_error = snapshot_error.read
# Send the email
@@ -61,7 +59,9 @@
:sender_address => config['send_from'],
:sender_name => config['send_from_name'],
:rsync_result => rsync_result,
+ :rsync_error => rsync_error,
:snapshot_result => snapshot_result,
+ :snapshot_error => snapshot_error,
:backup_start_time => backup_start
}
7 templates/email_notification.markdown.erb
View
@@ -3,3 +3,10 @@
<%= snapshot_result %>
The backup took <%= backup_time %>.
+
+Errors (if any)
+------------------------------------------------------------------------------
+
+<%= rsync_errors %>
+
+<%= snapshot_errors %>
Please sign in to comment.
Something went wrong with that request. Please try again.