Commit 8962ca0e authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Merge branch 'exit-code-branching' into 'master'

Add branching by rsync exit code

See merge request !47
parents 3c78b219 4556aadd
Pipeline #6642 passed with stages
in 42 seconds
......@@ -24,6 +24,7 @@ import configparser
import os
import subprocess
import sys
import time
parser = argparse.ArgumentParser(
description="Automatic backup script using backstep-traceback."
......@@ -109,7 +110,9 @@ else:
if bwlimit > 0:
syncopts.append("--bwlimit=" + str(bwlimit))
for lv in ast.literal_eval(config.get(PERIOD, "backup_lvs")):
stack = []
for lv in reversed(ast.literal_eval(config.get(PERIOD, "backup_lvs"))):
if args.only and args.only != lv:
continue
......@@ -163,7 +166,44 @@ for lv in ast.literal_eval(config.get(PERIOD, "backup_lvs")):
)
)
if not args.test:
EXIT_CODE = subprocess.call(command_line)
else:
print(command_line)
stack.append(command_line)
# Rsync Exit Values
# 0 Success
# 1 Syntax or usage error
# 2 Protocol incompatibility
# 3 Errors selecting input/output files, dirs
# 4 Requested action not supported
# 5 Error starting client-server protocol
# 6 Daemon unable to append to log-file
# 10 Error in socket I/O
# 11 Error in file I/O
# 12 Error in rsync protocol data stream
# 13 Errors with program diagnostics
# 14 Error in IPC code
# 20 Received SIGUSR1 or SIGINT
# 21 Some error returned by waitpid()
# 22 Error allocating core memory buffers
# 23 Partial transfer due to error
# 24 Partial transfer due to vanished source files
# 25 The --max-delete limit stopped deletions
# 30 Timeout in data send/receive
# 35 Timeout waiting for daemon connection
exit_list = [0, 1, 2, 3, 4, 6, 13, 14, 20, 21, 22, 24, 25]
wait_list = [5, 10, 11, 12, 23, 30, 35, 255]
while stack:
task = stack.pop()
EXIT_CODE = subprocess.call(task)
if EXIT_CODE in exit_list:
sys.exit(EXIT_CODE)
elif EXIT_CODE in wait_list:
stack.append(task)
if args.verbose:
print("Sleeping...")
time.sleep(3030)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment