summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorowsla <owsla@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2009-01-03 23:18:35 +0000
committerowsla <owsla@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2009-01-03 23:18:35 +0000
commit247258bb5cd325c311188dd65b3f351e64bc5454 (patch)
tree4dfb10c0835303245482954eaa9abefe7b54b495
parenta0d43616f7f51127bed7a8dd3866fa6d22b8c8b5 (diff)
downloadrdiff-backup-247258bb5cd325c311188dd65b3f351e64bc5454.tar.gz
New option: --use-compatible-timestamps, which causes rdiff-backup to use - asthe hour/minute/second separator instead of :. Enabled by default on systems
which require : to be escaped. (Oliver Mulatz) git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@996 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
-rw-r--r--rdiff-backup/CHANGELOG4
-rw-r--r--rdiff-backup/rdiff-backup.19
-rw-r--r--rdiff-backup/rdiff_backup/Globals.py5
-rw-r--r--rdiff-backup/rdiff_backup/Main.py6
-rw-r--r--rdiff-backup/rdiff_backup/Time.py20
-rw-r--r--rdiff-backup/rdiff_backup/fs_abilities.py9
6 files changed, 45 insertions, 8 deletions
diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG
index 45ef1e9..1ac61a2 100644
--- a/rdiff-backup/CHANGELOG
+++ b/rdiff-backup/CHANGELOG
@@ -1,6 +1,10 @@
New in v1.3.0 (????/??/??)
---------------------------
+New option: --use-compatible-timestamps, which causes rdiff-backup to use - as
+the hour/minute/second separator instead of :. Enabled by default on systems
+which require : to be escaped. (Oliver Mulatz)
+
Allow rdiff-backup to backup files which it cannot read, but can change
the permissions of. (Andrew Ferguson)
diff --git a/rdiff-backup/rdiff-backup.1 b/rdiff-backup/rdiff-backup.1
index 780c4d7..648f573 100644
--- a/rdiff-backup/rdiff-backup.1
+++ b/rdiff-backup/rdiff-backup.1
@@ -1,4 +1,4 @@
-.TH RDIFF-BACKUP 1 "DECEMBER 2008" "Version 1.2.3" "User Manuals" \" -*- nroff -*-
+.TH RDIFF-BACKUP 1 "JANUARY 2009" "Version 1.3.0" "User Manuals" \" -*- nroff -*-
.SH NAME
rdiff-backup \- local/remote mirror and incremental backup
.SH SYNOPSIS
@@ -486,6 +486,13 @@ Test for the presence of a compatible rdiff-backup server as specified
in the following host::filename argument(s). The filename section
will be ignored.
.TP
+.B \-\-use-compatible-timestamps
+Create timestamps in which the hour/minute/second separator is a - (hyphen)
+instead of a : (colon). It is safe to use this option on one backup, and then
+not use it on another; rdiff-backup supports the intermingling of different
+timestamp formats. This option is enabled by default on platforms which
+require that the colon be escaped.
+.TP
.BI "\-\-user-mapping-file " filename
Map user names and ids according to the user mapping file
.IR filename .
diff --git a/rdiff-backup/rdiff_backup/Globals.py b/rdiff-backup/rdiff_backup/Globals.py
index ffccc27..ab26abf 100644
--- a/rdiff-backup/rdiff_backup/Globals.py
+++ b/rdiff-backup/rdiff_backup/Globals.py
@@ -159,6 +159,11 @@ rbdir = None
chars_to_quote = None
quoting_char = ';'
+# If true, the timestamps use the following format: "2008-09-01T04-49-04-07-00"
+# (instead of "2008-09-01T04:49:04-07:00"). This creates timestamps which
+# don't need to be escaped on Windows.
+use_compatible_timestamps = 0
+
# If true, emit output intended to be easily readable by a
# computer. False means output is intended for humans.
parsable_output = None
diff --git a/rdiff-backup/rdiff_backup/Main.py b/rdiff-backup/rdiff_backup/Main.py
index 7283bfb..46a3767 100644
--- a/rdiff-backup/rdiff_backup/Main.py
+++ b/rdiff-backup/rdiff_backup/Main.py
@@ -85,8 +85,8 @@ def parse_cmdlineoptions(arglist):
"remove-older-than=", "restore-as-of=", "restrict=",
"restrict-read-only=", "restrict-update-only=", "server",
"ssh-no-compression", "tempdir=", "terminal-verbosity=",
- "test-server", "user-mapping-file=", "verbosity=", "verify",
- "verify-at-time=", "version"])
+ "test-server", "use-compatible-timestamps", "user-mapping-file=",
+ "verbosity=", "verify", "verify-at-time=", "version"])
except getopt.error, e:
commandline_error("Bad commandline options: " + str(e))
@@ -199,6 +199,8 @@ def parse_cmdlineoptions(arglist):
elif opt == "--tempdir": tempfile.tempdir = arg
elif opt == "--terminal-verbosity": Log.setterm_verbosity(arg)
elif opt == "--test-server": action = "test-server"
+ elif opt == "use-compatible-timestamps":
+ Globals.set("use_compatible_timestamps", 1)
elif opt == "--user-mapping-file": user_mapping_filename = arg
elif opt == "-v" or opt == "--verbosity": Log.setverbosity(arg)
elif opt == "--verify": action, restore_timestr = "verify", "now"
diff --git a/rdiff-backup/rdiff_backup/Time.py b/rdiff-backup/rdiff_backup/Time.py
index fee2276..02e3eeb 100644
--- a/rdiff-backup/rdiff_backup/Time.py
+++ b/rdiff-backup/rdiff_backup/Time.py
@@ -61,8 +61,13 @@ def setprevtime_local(timeinseconds, timestr):
prevtime, prevtimestr = timeinseconds, timestr
def timetostring(timeinseconds):
- """Return w3 datetime compliant listing of timeinseconds"""
- s = time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime(timeinseconds))
+ """Return w3 datetime compliant listing of timeinseconds, or one in
+ which :'s have been replaced with -'s"""
+ if not Globals.use_compatible_timestamps:
+ format_string = "%Y-%m-%dT%H:%M:%S"
+ else:
+ format_string = "%Y-%m-%dT%H-%M-%S"
+ s = time.strftime(format_string, time.localtime(timeinseconds))
return s + gettzd(timeinseconds)
def stringtotime(timestring):
@@ -72,10 +77,13 @@ def stringtotime(timestring):
like a w3 datetime string, return None.
"""
+
+ regexp = re.compile('[-:]')
+
try:
date, daytime = timestring[:19].split("T")
year, month, day = map(int, date.split("-"))
- hour, minute, second = map(int, daytime.split(":"))
+ hour, minute, second = map(int, regexp.split(daytime))
assert 1900 < year < 2100, year
assert 1 <= month <= 12
assert 1 <= day <= 31
@@ -157,16 +165,18 @@ def gettzd(timeinseconds = None):
elif offset < 0: prefix = "-"
else: return "Z" # time is already in UTC
+ if Globals.use_compatible_timestamps: time_separator = '-'
+ else: time_separator = ':'
hours, minutes = map(abs, divmod(offset, 60))
assert 0 <= hours <= 23
assert 0 <= minutes <= 59
- return "%s%02d:%02d" % (prefix, hours, minutes)
+ return "%s%02d%s%02d" % (prefix, hours, time_separator, minutes)
def tzdtoseconds(tzd):
"""Given w3 compliant TZD, return how far ahead UTC is"""
if tzd == "Z": return 0
assert len(tzd) == 6 # only accept forms like +08:00 for now
- assert (tzd[0] == "-" or tzd[0] == "+") and tzd[3] == ":"
+ assert (tzd[0] == "-" or tzd[0] == "+") and (tzd[3] == ":" or tzd[3] == "-")
return -60 * (60 * int(tzd[:3]) + int(tzd[4:]))
def cmp(time1, time2):
diff --git a/rdiff-backup/rdiff_backup/fs_abilities.py b/rdiff-backup/rdiff_backup/fs_abilities.py
index 10cbb27..dec2822 100644
--- a/rdiff-backup/rdiff_backup/fs_abilities.py
+++ b/rdiff-backup/rdiff_backup/fs_abilities.py
@@ -708,6 +708,12 @@ class SetGlobals:
def set_symlink_perms(self):
SetConnections.UpdateGlobal('symlink_perms',
self.dest_fsa.symlink_perms)
+
+ def set_compatible_timestamps(self):
+ if Globals.chars_to_quote.find(":") > -1:
+ SetConnections.UpdateGlobal('use_compatible_timestamps', 1)
+ log.Log("Enabled use_compatible_timestamps", 4)
+
class BackupSetGlobals(SetGlobals):
"""Functions for setting fsa related globals for backup session"""
@@ -963,6 +969,7 @@ def backup_set_globals(rpin, force):
bsg.set_symlink_perms()
update_quoting = bsg.set_chars_to_quote(Globals.rbdir, force)
bsg.set_special_escapes(Globals.rbdir)
+ bsg.set_compatible_timestamps()
if update_quoting and force:
FilenameMapping.update_quoting(Globals.rbdir)
@@ -990,6 +997,7 @@ def restore_set_globals(rpout):
rsg.set_symlink_perms()
rsg.set_chars_to_quote(Globals.rbdir)
rsg.set_special_escapes(Globals.rbdir)
+ rsg.set_compatible_timestamps()
def single_set_globals(rp, read_only = None):
"""Set fsa related globals for operation on single filesystem"""
@@ -1010,4 +1018,5 @@ def single_set_globals(rp, read_only = None):
ssg.set_symlink_perms()
ssg.set_chars_to_quote(Globals.rbdir)
ssg.set_special_escapes(Globals.rbdir)
+ ssg.set_compatible_timestamps()