summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2015-08-11 16:00:10 +0300
committerSteve Kemp <steve@steve.org.uk>2015-08-11 16:00:10 +0300
commitf70c16cb5e236416d276aea54c4f65d6a7a74484 (patch)
tree8f5a715fba1860f74b94f3071388bbf2559da948
parent7462f7d3050f86e6fdebff04151b3a44eaa7f1ac (diff)
Allow I/O timeout to be specified.
Rather than having a hard-wired value we now allow this to be specified on the command-line: --io-timeout=7200 Or in a file: /etc/byteback/io_timeout
-rwxr-xr-xbin/byteback-backup29
1 files changed, 23 insertions, 6 deletions
diff --git a/bin/byteback-backup b/bin/byteback-backup
index 2e37e66..11ed312 100755
--- a/bin/byteback-backup
+++ b/bin/byteback-backup
@@ -38,6 +38,10 @@ opts = Trollop.options do
:type => :integer,
:default => 3
+ opt :io_timeout, 'Number of seconds to allow I/O timeout for',
+ :type => :integer,
+ :default => 21600
+
opt :retry_delay, 'Number of seconds between retries after an error',
:type => :integer,
:default => 300
@@ -62,6 +66,8 @@ lock_out_other_processes('byteback-backup')
@destination = opts[:destination]
@retry_number = opts[:retry_number]
@retry_delay = opts[:retry_delay]
+@io_timeout = opts[:io_timeout] if opts[:io_timeout]
+
# Read the default destination
if File.exist?('/etc/byteback/destination')
@@ -73,6 +79,12 @@ if File.exist?('/etc/byteback/key')
@ssh_key = '/etc/byteback/key'
end
+# If we have a local timeout-file then use that
+if File.exist?('/etc/byteback/io_timeout')
+ @io_timeout = File.foreach('/etc/byteback/io_timeout').first.to_i
+end
+
+
#
# Check our destination
#
@@ -175,13 +187,18 @@ def rsync(*sources)
# at the end of the job, and rsync will do more work for big files without
# it.
#
- # The timeout is set to 6 hours - rsync can spend a long time at the
- # far end checking over its files at the far end without transfer, so we
- # want to wait as long as possible without jeopardising the timing of the
- # next backup run. Obviously if rsync itself takes nearly 24 hours for a
- # given filesystem, daily backups (with this tool) are out of the question.
+ # rsync can spend a long time at the far end checking over its files at
+ # the far end without transfer, so we want to wait as long as possible
+ # without jeopardising the timing of the next backup run.
#
- args = %w( rsync --archive --numeric-ids --delete-delay --inplace --relative --timeout 21600 )
+ #
+ args = %w( rsync --archive --numeric-ids --delete-delay --inplace --relative )
+
+ #
+ # Add on the I/O-timeout
+ #
+ args += ['--timeout', @io_timeout ] unless ( @io_timeout.nil? )
+
args += ['--rsh', "ssh -o BatchMode=yes -x -a -i #{@ssh_key} -l #{@destination_user}"]
args << '--verbose' if @verbose