Commit 5aea6fac authored by Daniel Armbruster's avatar Daniel Armbruster Committed by thomas.forbriger
Browse files

introduced rsync option flag

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: 5064
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 3fb1f099
......@@ -39,6 +39,7 @@
# exception in case of no checksum was available for a
# data file; use rsync based on timestamp comparison
# (faster than based on checksum comparison [-c])
# 15/03/2013 V1.1 introduced additional [-o|--rsync-opts ARG] flags
#
# ============================================================================
#
......@@ -55,7 +56,7 @@ import csbackErrorCodes as eCodes
import csbacklog
import pidlock
__version__ = "V1.0.2"
__version__ = "V1.1"
__subversion__ = "$Id$"
__license__ = "GPLv2+"
__author__ = "Daniel Armbruster"
......@@ -68,7 +69,8 @@ USAGE_TEXT = "Version: "+__version__+"\nLicense: "+__license__+ \
"\n"+__subversion__+"\nAuthor: "+__author__+ """
Usage: csbackscp [-v|--verbose] [-d|--debug] [-l|--logging] [-L|--Lock ARG]
[-e|--exclude REGEX [-e|--exclude REGEX [...]]] [-n|--dry-run]
[-c|--copy ARG] [-N|-newer ARG] SOURCE TARGET
[-c|--copy ARG] [-N|-newer ARG] [-o|--rsync-opts ARG]
SOURCE TARGET
or: csbackscp -h|--help\n"""
# -----------------------------------------------------------------------------
......@@ -81,40 +83,46 @@ def help():
"""
help_text = USAGE_TEXT+"""
-------------------------------------------------------------------------------
-v|--verbose Be verbose.
-h|--help Display this help.
-d|--debug Debug mode. Be really verbose.
-l|--logging Switch on logging to files. Logfiles will be located in
/var/log/ .
-L|--lock ARG Lock the directories working at. ARG is the timeout in
seconds csbackscp is waiting on locked directories until the
program terminates. This flag is useful in case csbackscp
was run simultaneously with other csback processes working
in the same directory. Setting this option avoids
checksumfile access problems which might occur. If not
enabled csbackscp will not care about locked directories.
-e|--exclude REGEX Exclude files and directories from copy process matching
REGEX. The option may be used several times on the same
commandline. Note, that the 'rsync exclude pattern rules'
are in use. For further information see the man pages of
rsync.
-n|--dry-run Perform a trial run with no changes made.
-c|--copy Specify the copy command (including commandline options) to
use (default: 'scp -qB').
-N|--newer ARG Consider only files which are newer than ARG. ARG directly
will be passed to the *nix 'find' command. Consequently the
syntax of ARG identical to the syntax of the program 'find'.
See also the 'find' info page.
Note that this option requires a version of the find program
>= V4.3.3.
SOURCE Source directory (base) where original data files are
located. Only data files with a valid checksum are taken
into account and copied to TARGET. Subdirectories of SOURCE
are also taken into account.
TARGET Target directory (base) where copy of data files is stored.
Note, that the directory tree (including subdirectories) of
SOURCE will be preserved.
Note, that TARGET may also be of type [USER@]HOST:DEST.
-v|--verbose Be verbose.
-h|--help Display this help.
-d|--debug Debug mode. Be really verbose.
-l|--logging Switch on logging to files. Logfiles will be located in
/var/log/ .
-L|--lock ARG Lock the directories working at. ARG is the timeout in
seconds csbackscp is waiting on locked directories until
the program terminates. This flag is useful in case
csbackscp was run simultaneously with other csback
processes working in the same directory. Setting this
option avoids checksumfile access problems which might
occur. If not enabled csbackscp will not care about locked
directories.
-e|--exclude REGEX Exclude files and directories from copy process matching
REGEX. The option may be used several times on the same
commandline. Note, that the 'rsync exclude pattern rules'
are in use. For further information see the man pages of
rsync.
-n|--dry-run Perform a trial run with no changes made.
-c|--copy Specify the copy command (including commandline options)
to use (default: 'scp -qB').
-N|--newer ARG Consider only files which are newer than ARG. ARG directly
will be passed to the *nix 'find' command. Consequently
the syntax of ARG identical to the syntax of the program
'find'. See also the 'find' info page.
Note that this option requires a version of the find
program >= V4.3.3.
-o|--rsync-opts ARG Additional options which will be passed directly to rsync.
This flag might be useful in case of not preserving
timestamps while copying such that the rsync timestamp
comparison has no effect. In these cases a comparison
based on checksums would be the matter of choice.
SOURCE Source directory (base) where original data files are
located. Only data files with a valid checksum are taken
into account and copied to TARGET. Subdirectories of
SOURCE are also taken into account.
TARGET Target directory (base) where copy of data files is
stored. Note, that the directory tree (including
subdirectories) of SOURCE will be preserved. Note as well,
that TARGET may also be of type [USER@]HOST:DEST.
-------------------------------------------------------------------------------
Note, that this tool strongly relies on the *NIX tool 'rsync'. Based on
timestamp comparison files are selected which would be copied to TARGET by
......@@ -159,9 +167,9 @@ def main(argv=None):
argv = sys.argv
try:
try:
opts, args = getopt.getopt(argv[1:], "vhdlL:e:nc:N:", ["help", \
opts, args = getopt.getopt(argv[1:], "vhdlL:e:nc:N:o:", ["help", \
"verbose", "debug", "logging", "Lock=", "exclude=", "dry-run", \
"copy=", "newer="])
"copy=", "newer=", "rsync-opts="])
except getopt.GetoptError as err:
raise Usage(err.msg, eCodes.GLOBAL_UsageError)
verbose = False
......@@ -170,6 +178,7 @@ def main(argv=None):
pidLock = False
copyCommand=["scp", "-qB"]
newerOpt = None
rsyncOpts = None
# immediately exclude csback specific files (rsync exclusion pattern syntax)
# from copy process
regexes = [pidlock.LOCKFILENAME , csf.BASENAME+csf.RESULTSUFFIX+'*']
......@@ -202,6 +211,8 @@ def main(argv=None):
elif opt in ("-N", "--newer"):
pos=arg.find(" ")
newerOpt=[arg[0:pos], arg[pos+1:]]
elif opt in ("-o", "--rsync-opts"):
rsyncOpts = arg
else:
raise Usage("Unhandled option chosen.", eCodes.GLOBAL_UnhandledOption)
......@@ -233,6 +244,8 @@ def main(argv=None):
logger.getLogger().info( \
"Checking which data files would be copied by rsync ...")
rsyncCmd = ["rsync", "-an", "--out-format=%n"]
if rsyncOpts:
rsyncCmd.append(rsyncOpts)
if newerOpt is not None:
logger.getLogger().info("Taking time dependence into consideration.")
......
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