Commit 3c78b219 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Merge branch 'testing' into 'master'

Add comand line parameter and code for testing

See merge request !46
parents 975fdb84 7c9d3e6f
Pipeline #6639 passed with stages
in 42 seconds
......@@ -40,6 +40,12 @@ group.add_argument("-w", "--weekly", action="store_true", help="Do weekly backup
parser.add_argument(
"-o", "--only", help="Only do a backup of the specified lv", metavar="lv_name"
)
parser.add_argument(
"-t",
"--test",
action="store_true",
help="Don't do anything, only show what would have been run.",
)
args = parser.parse_args()
if args.daily:
......@@ -50,7 +56,10 @@ else:
print("error: You need to specify a period [daily or weekly].")
sys.exit(2)
CONFIG_FILE = "/etc/backstep-traceback/backstep-traceback-auto.ini"
if not args.test:
CONFIG_FILE = "/etc/backstep-traceback/backstep-traceback-auto.ini"
else:
CONFIG_FILE = "backstep-traceback-auto.ini"
if not os.path.exists(CONFIG_FILE):
print("error: backup is not configured.")
......@@ -74,7 +83,8 @@ report_email = config.get(PERIOD, "report_email")
server_host = config.get(PERIOD, "server_host")
server_key = config.get(PERIOD, "server_key")
if not os.path.exists(server_key):
if not args.test:
if not os.path.exists(server_key):
print("error: " + server_key + " does not exist.")
sys.exit(2)
......@@ -83,7 +93,8 @@ server_port = config.getint(PERIOD, "server_port")
server_user = config.get(PERIOD, "server_user")
zabbix_config = config.get(PERIOD, "zabbix_config")
if not os.path.exists(zabbix_config):
if not args.test:
if not os.path.exists(zabbix_config):
print("error: " + zabbix_config + " does not exist.")
sys.exit(2)
......@@ -105,12 +116,15 @@ for lv in ast.literal_eval(config.get(PERIOD, "backup_lvs")):
bind_mount_args = []
lvm_snapshot_args = []
if not args.test:
if os.path.exists("/dev/lvm-raid/" + lv):
VG = "lvm-raid"
elif os.path.exists("/dev/lvm-cache/" + lv):
VG = "lvm-cache"
else:
continue
else:
VG = "lvm-raid"
if lv == "root":
bind_mount_args.append("--bind-mount")
......@@ -149,4 +163,7 @@ 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)
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