2019-04-23 23:15:51 -07:00
|
|
|
#!/usr/bin/python3
|
|
|
|
"""
|
|
|
|
.. moduleauthor:: Eric Torres
|
|
|
|
|
|
|
|
Command-Line Arguments
|
|
|
|
======================
|
|
|
|
|
|
|
|
A daemon that waits to run backup jobs and manages a
|
|
|
|
Repository on the local system.
|
|
|
|
|
|
|
|
backupd listens on a specified port for a backup job sent
|
|
|
|
by the backup script and
|
|
|
|
|
|
|
|
TODO inspect python-daemon for use with this script
|
|
|
|
"""
|
|
|
|
|
2019-04-28 22:20:49 -07:00
|
|
|
import argparse
|
2019-04-23 23:15:51 -07:00
|
|
|
import daemon
|
|
|
|
import logging
|
2019-04-28 22:20:49 -07:00
|
|
|
import rbackup.logging
|
2019-04-23 23:15:51 -07:00
|
|
|
|
|
|
|
from rbackup.struct.repository import Repository
|
|
|
|
|
|
|
|
# ========== Constants ==========
|
|
|
|
|
|
|
|
|
|
|
|
# ========== Functions ==========
|
|
|
|
def parse_cmdline_arguments(**kwargs):
|
|
|
|
"""Parse command line arguments passed to the script.
|
|
|
|
All kwargs are passed to ArgumentParser.parse_args().
|
|
|
|
|
|
|
|
:rtype: argparse.Namespace object
|
|
|
|
"""
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument("repository", help="repository to back up to", metavar="repo")
|
|
|
|
|
|
|
|
return parser.parse_args(**kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
# ========== Logging Setup ==========
|
|
|
|
syslog = logging.getLogger("rbackup")
|
|
|
|
syslog.setLevel(logging.DEBUG)
|
|
|
|
|
|
|
|
|
|
|
|
# ========== Main Program ==========
|
|
|
|
if __name__ == "__main__":
|
2019-04-28 22:20:49 -07:00
|
|
|
args = parse_cmdline_arguments()
|
|
|
|
|
|
|
|
stdout_handler, stderr_handler = rbackup.logging.retrieve_console_handlers(
|
|
|
|
debug=args.debug
|
|
|
|
)
|
|
|
|
syslog.addHandler(stdout_handler)
|
|
|
|
syslog.addHandler(stderr_handler)
|
|
|
|
|
2019-04-23 23:15:51 -07:00
|
|
|
with daemon.DaemonContext():
|
|
|
|
pass
|