Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
@@ -39,13 +39,13 @@ def create_email(params)
39 39 # params = :name (send_to_name), :address (send_to_address), :rsync_result,
40 40 # :email_server (email_server), :sender_name (send_from_name),
41 41 # :sender_address (send_from_address), :backup_start_time
42   - # :snapshot_result
  42 + # :snapshot_result, :rsync_error, :snapshot_error
43 43
44 44 email_subject = 'Disk-to-disk backup results'
45 45
46 46 email_template = File.read(EMAIL_TEMPLATE_LOCATION)
47 47 email_eruby = Erubis::FastEruby.new(email_template)
48   - erb_binding = { :rsync_result => params[:rsync_result], :snapshot_result => params[:snapshot_result], :backup_time => determine_time(params[:backup_start_time]) }
  48 + 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]}
49 49 email_markdown = Markdown.new(email_eruby.result(erb_binding))
50 50
51 51 # return this object
14 rbRsyncWrapper.rb
@@ -37,10 +37,9 @@
37 37 /mnt/btr_pool/files_share_backup/ \
38 38 --sockopts=SO_SNDBUF=4194304,SO_RCVBUF=4194304"
39 39
40   -stdin, rsync_result, stderr = Open3.popen3(rsync_command)
41   -rsync_result = rsync_result.read.split.join(" \n")
42   -
43   -puts rsync_result
  40 +stdin, rsync_result, rsync_error = Open3.popen3(rsync_command)
  41 +rsync_result = rsync_result.read.split($/).join(" #{$/}")
  42 +rsync_error = rsync_error.read
44 43
45 44 # do the snapshot
46 45
@@ -48,10 +47,9 @@
48 47 /mnt/btr_pool/files_share_backup /mnt/btr_pool/\
49 48 files_share_backup-snap-#{backup_start.strftime("%Y.%m.%d-%H.%M.%S")}"
50 49
51   -stdin, snapshot_result, stderr = Open3.popen3(snapshot_command)
  50 +stdin, snapshot_result, snapshot_error = Open3.popen3(snapshot_command)
52 51 snapshot_result = snapshot_result.read
53   -
54   -puts snapshot_result
  52 +snapshot_error = snapshot_error.read
55 53
56 54 # Send the email
57 55
@@ -61,7 +59,9 @@
61 59 :sender_address => config['send_from'],
62 60 :sender_name => config['send_from_name'],
63 61 :rsync_result => rsync_result,
  62 + :rsync_error => rsync_error,
64 63 :snapshot_result => snapshot_result,
  64 + :snapshot_error => snapshot_error,
65 65 :backup_start_time => backup_start
66 66 }
67 67
7 templates/email_notification.markdown.erb
@@ -3,3 +3,10 @@
3 3 <%= snapshot_result %>
4 4
5 5 The backup took <%= backup_time %>.
  6 +
  7 +Errors (if any)
  8 +------------------------------------------------------------------------------
  9 +
  10 +<%= rsync_errors %>
  11 +
  12 +<%= snapshot_errors %>

0 comments on commit 0a93288

Please sign in to comment.
Something went wrong with that request. Please try again.