Commit 3302cca2 authored by Daniel Armbruster's avatar Daniel Armbruster Committed by thomas.forbriger
Browse files

Started new project (csback) - proceeding

This is a legacy commit from before 2015-05-18.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.

SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 4130
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parents
This is a legacy version of the repository. It may be incomplete as well as
inconsistent. See README.history for details. For the old stock of the
repository copyright and licence conditions apply as specified for versions
commited after 2015-05-18. Use recent versions as a base for new development.
The legacy version is only stored to keep a record of history.
this is <README>
===============================================================================
csback - A software suite and toolkit to manage backups.
--------------------------
$Id$
===============================================================================
csback is a software suite and toolkit of tools to manage backups and test
their integrity from time to time. The tools are completely written in python
and should work both in python 2 and python 3. Because of avoiding to write
already available tools twice, csback falls back to tools like cron and rsync
when possible. These tools already should be installed on a large range of *nix
operating systems.
----
Installation:
----
...
----
General approach to use csback:
----
Write a configuration file like csbackrc and generate a crontab by using
csback2cron. You don't need to care about the sequence in which to tools are
applied. Just set up a setting line as described in the enclosed configuration
file.
Next use the crontab command to install the generated crontab. Remember that you
need a working cron deamon as well as the rsync tool.
----
Properties and advantages of csback:
----
- Test the integrity of your files backed up from time to time. If an error or
occurs or there is a violation of the integrity of a file there is the
possibility to send an email to inform the admin about the current status.
- Use the toolkit just to test if a given directory contains files which are
having integrity. Remember that only directories can be tested if they already
are containing a so called checksum file.
- The tools completely are written in python and should work under both Python
>2.6 and Python 3.x
- Because of its modular approach and of using already existing and well tested
tools working with csback treats your resources carefully.
----- END OF README -----
this is <README.history>
============================================================================
history of this repository
--------------------------
2015-05-18
============================================================================
Brief history
-------------
The contents of this repository previously were part of the TFSoftware
repository. They were extracted into a git repository on 2015-05-18.
----------------------------------------------------------------------------
Milestones
----------
2000-02-09 Initial import to CVS repository
tag: thof_initial_commit
2010-08-08 Conversion to subversion
tag: cvs-svn_conversion
2014-01-01 Check-out with git-svn creating a gatekeeper repository
tag: git-svn_gatekeeper_clone
2015-05-18 Creation of git repository
tags: surgery_*
----- END OF README.history -----
#!/usr/bin/env python
## @file csback2cron.py
# @brief Generate a crontab for the csback software suite.
#
# -----------------------------------------------------------------------------
#
# $Id$
# @author Daniel Armbruster
# \date 11/09/2011
#
# Purpose: Generate a crontab for the csback toolkit using the a configuration
# file.
#
# ----
# This file is part of csback.
#
# csback 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 3 of the License, or
# (at your option) any later version.
#
# csback 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 csback. If not, see <http://www.gnu.org/licenses/>.
# ----
#
# Copyright (c) 2011 by Daniel Armbruster
#
# REVISIONS and CHANGES
# 11/09/2011 V0.1 Daniel Armbruster
#
# =============================================================================
import sys
import getopt
import os
import pwd
import string
version="cscron2back V0.1"
license="GPL"
class Usage(Exception):
def __init__(self, msg):
self.msg = msg
def display(self):
usage_text = version + "\nLicense:" + license + "\n" + """
Author: Daniel Armbruster
Usage: csback2cron [-v] [-i CONFIGFILE] <CRONTABFILENAME>
or: csback2cron -h
Note: If [-i CONFIGFILE] isn't passed as a argument, csback2cron uses
~/.csbackrc\n"""
if sys.version_info >= (3,)
print("csback2cron:" + self.msg, file=sys.stderr)
print(usage_text, file=sys.stderr)
else:
print >>sys.stderr, "csback2cron:" + self.msg
print >>sys.stderr, usage_text
# -----------------------------------------------------------------------------
def help():
help_text = version + "\nLicense:" + license + "\n" + """
Author: Daniel Armbruster
Usage: csback2cron [-v] [-i CONFIGFILE] <CRONTABFILENAME>
or: csback2cron -h
------------------------------------------------------------------------
-v/--verbose Be verbose.
-h/--help Display this help.
-i CONFIGFILE Path to csbackrc - the configuration file of csback.
If this argument wasn't passed csback2cron assumes
~/.csbackrc as default argument.
<CRONTABFILENAME> Outputfilename of the generated crontab.\n"""
print(help_text)
# -----------------------------------------------------------------------------
def get_username():
return pwd.getpwuid(os.getuid()).pw_name
# -----------------------------------------------------------------------------
class Processor():
def __init__(self, configfile, crontabfile):
self.__configfile = str(configfile)
self.__crontabfile = str(crontabfile)
def read(self):
configfile = open(self.__configfile)
def convert(self):
def write(self):
# -----------------------------------------------------------------------------
def main(argv=None):
if argv is None:
argv = sys.argv
try:
try:
opts, args = getopt.getopt(argv[1:], "hvi:", ["help", "verbose"])
except getopt.error, msg:
raise Usage(msg)
if len(args) == 0
raise Usage("CRONTABFILENAME not given.")
output = None
input = '/home/' + get_username()+ '/.csbackrc'
verbose = False
for opt, a in opts:
if opt == "-v":
verbose = True
elif opt in ("-h", "--help"):
help()
sys.exit()
elif opt in ("-i", "--input"):
input = a
else:
raise Usage("Unhandled option chosen.")
data = read()
except Usage as err:
err.display()
return 2
# -----------------------------------------------------------------------------
if __name__ == "__main__":
sys.exit(main())
# ----- END OF csback2cron.py -----
# This is <csbackrc>
# ----------------------------------------------------------------------------
# $Id$
#
# Copyright (c) 2011 by Daniel Armbruster (BFO Schiltach)
#
# Configuration file for csback.
#
# this file should be placed in the home directory as file
# ~/.csbackrc
# edit this file to suit your needs
#
#
# REVISIONS and CHANGES
# 11/09/2010 V1.0 Daniel Armbruster
#
# ============================================================================
#
# Enter the desired backup settings here in this file. Then use csback2cron to
# generate a crontab.
# Next use the usual crontab commands to install to generated crontab. If you
# need more information how to install a crontab read the corresponding man
# pages.
#
# An example setting line is given here.
# -----------------------------------------------------------------------------
# CRONEXPR SOURCE TARGET FLAGS
# -----------------------------------------------------------------------------
#
# Example 1)
#
# * */10 * * * /data /data.bak -e *log
#
# This line will perform a backup of /data exluding subdirectories matching the
# pattern *log to /data.bak every ten hours.
#
# Example 2)
#
# Another possibility is to set up a line as follows, if only a test of a
# special directory (e.g. /data.bak) is wished.
#
# * * */3 * * /data.bak -t -e *log
#
# CRONEXPR:
# With the cron expression you're able to schedule your backup. For further
# information how to write cron expressions read the cron man page.
#
# SOURCE:
# The source directory which will be backed up.
#
# TARGET:
# The target directory where to locate the files which were backed up.
#
# FLAGS:
# Possible flags are
# [-c] Perform a test of the TARGET and the SOURCE directory.
# Default after executing a backup is only to check the TARGET
# directory for integrity.
# [-t] Be tolerant. While checking don't report anything if a file
# listed in the checksumfile is missing. This flag is useful if a
# test of a SOURCE directory is executed but SOURCE is realized
# e.g. as a ring buffer.
# [-b] Only perform a backup. First an update of the checksumfile will
# be executed to perform afterwards a backup. A test of the
# TARGET directory won't be executed as well as the [-c] and [-t]
# flags are ignored.
# If only one directory is given csback assumes that only testing
# the integrity of the corresponding directory is desired.
# [-e regexp ] A pattern which contains a regular expression to exclude
# subdirectories of SOURCE matching the regular expression.
#
# Note:
# If there is any of the options [-c] [-b] [-t] given a the default is to
# perform a backup including a test of the TARGET directory.
# If no option [-e regexp] is given the whole SOURCE directory will be backed
# up.
#
# Put your setting lines below.
# ----
# Additionally there is the possibility report the current status by sending an
# email to the mailaddresses given below. By default csback will send one email
# per day. If there isn't any mailaddress given csback will skip this option.
#
# Mailadresses should be given as follows (e.g.):
# mail= add1@server1.com add2@server2.com
mail=
# ----- END OF csbackrc -----
Markdown is supported
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