summaryrefslogtreecommitdiff
path: root/obnam
diff options
context:
space:
mode:
authorLars Wirzenius <liw@gytha>2008-06-10 22:22:51 +0300
committerLars Wirzenius <liw@gytha>2008-06-10 22:22:51 +0300
commite77315091d8c0ac3cd040b85914aff0291b5fa5f (patch)
treed79fb6bc260d3e798e38af4ebef39860b6fd02c3 /obnam
parent4b378dde1770d97d1aab9f460685093d733a717c (diff)
downloadobnam-e77315091d8c0ac3cd040b85914aff0291b5fa5f.tar.gz
Renamed cli.py to obnam.
Diffstat (limited to 'obnam')
-rwxr-xr-xobnam82
1 files changed, 82 insertions, 0 deletions
diff --git a/obnam b/obnam
new file mode 100755
index 00000000..2922dd0b
--- /dev/null
+++ b/obnam
@@ -0,0 +1,82 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2006, 2007, 2008 Lars Wirzenius <liw@iki.fi>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+"""A backup program"""
+
+
+import logging
+import sys
+import traceback
+
+import obnam
+
+
+def main():
+ try:
+ context = obnam.context.Context()
+ args = obnam.config.parse_options(context.config, sys.argv[1:])
+ context.cache = obnam.cache.Cache(context.config)
+ context.be = obnam.backend.init(context.config, context.cache)
+ context.be.set_progress_reporter(context.progress)
+ app = obnam.Application(context)
+
+ obnam.log.setup(context.config)
+
+ logging.info("%s %s starting up" % (obnam.NAME, obnam.VERSION))
+
+ try:
+ factory = obnam.OperationFactory(app)
+ oper = factory.get_operation(args)
+ oper.do_it(args[1:])
+
+ logging.info("Store I/O: %d kB read, %d kB written" %
+ (context.be.get_bytes_read() / 1024,
+ context.be.get_bytes_written() / 1024))
+ logging.info("Obnam finishing")
+ context.progress.final_report()
+ if app.get_store():
+ app.get_store().close()
+ except KeyboardInterrupt:
+ logging.warning("Obnam interrupted by Control-C, aborting.")
+ logging.warning("Note that backup has not been completed.")
+ sys.stderr.write("Obnam interrupted by Control-C, aborting.\n")
+ sys.stderr.write("Note that backup has not been completed.\n")
+ if app.get_store():
+ app.get_store().close()
+ sys.exit(1)
+ except obnam.ObnamException, e:
+ logging.error("%s" % str(e))
+ sys.stderr.write("%s\n" % str(e))
+ if app.get_store():
+ app.get_store().close()
+ sys.exit(1)
+ except SystemExit:
+ sys.exit(1)
+ except BaseException, e:
+ logging.error("%s" % repr(e))
+ logging.error("%s" % traceback.format_exc())
+ sys.stderr.write("%s\n" % repr(e))
+ sys.stderr.write("%s\n" % traceback.format_exc())
+ if app.get_store():
+ app.get_store().close()
+ sys.exit(1)
+
+
+if __name__ == "__main__":
+ main()