[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Duplicity-talk] Patch introducing --full-if-older-than
From: |
Olivier Croquette |
Subject: |
[Duplicity-talk] Patch introducing --full-if-older-than |
Date: |
Wed, 26 Sep 2007 23:08:25 +0200 |
User-agent: |
Thunderbird 2.0.0.4 (Macintosh/20070604) |
Hi!
I want to make regularly full backups for 2 reasons:
- be on the safe side and have regular reliable snapshots
- be able to clean up the older versions regularly
To facilitate this, I have implemented a new option
"--full-if-older-than", which will force a full backup in case an
incremental is requested, but the last full backup is too old according
to the time specified.
Comments are welcome.
Note that I have not compiled the patched man page, and I am not an
expert, so there might be formatting problems there...
PS: is there a recommend to provide patches, or are this kind of diff's
as attachments ok?
Regards
--
Olivier
diff -ru --ignore-matching-lines '^#!' duplicity-0.4.3.org/duplicity
duplicity-0.4.3-oliv/duplicity
--- duplicity-0.4.3.org/duplicity 2007-08-20 17:19:25.000000000 +0200
+++ duplicity-0.4.3-oliv/duplicity 2007-09-26 22:44:01.000000000 +0200
@@ -354,6 +354,11 @@
globals.archive_dir).set_values()
log.Log("Collection Status\n-----------------\n" + str(col_stats), 8)
+ log.Log("Last full backup date: " +
dup_time.timetopretty(col_stats.get_last_full_backup()), 4)
+ if action == "inc" and col_stats.get_last_full_backup() <
globals.full_force_time:
+ log.Log("Last full backup is too old, forcing full backup", 3)
+ action = "full"
+
os.umask(077)
globals.gpg_profile.passphrase = get_passphrase()
if action == "restore": restore(col_stats)
diff -ru --ignore-matching-lines '^#!' duplicity-0.4.3.org/duplicity.1
duplicity-0.4.3-oliv/duplicity.1
--- duplicity-0.4.3.org/duplicity.1 2007-08-20 17:19:25.000000000 +0200
+++ duplicity-0.4.3-oliv/duplicity.1 2007-09-26 22:57:09.000000000 +0200
@@ -195,6 +195,14 @@
Indicate full backup. If this is set, perform full backup even if
signatures are available.
.TP
+.BI "--full-if-older-than " time
+Perform a full backup if an incremental backup is requested, but the
+latest full backup in the collection is older than the given
+.I time
+. See the
+.B TIME FORMATS
+section for more information.
+.TP
.B --force
Proceed even if data loss might result. Duplicity will let the user
know when this option is required.
diff -ru --ignore-matching-lines '^#!' duplicity-0.4.3.org/src/collections.py
duplicity-0.4.3-oliv/src/collections.py
--- duplicity-0.4.3.org/src/collections.py 2007-08-20 17:19:25.000000000
+0200
+++ duplicity-0.4.3-oliv/src/collections.py 2007-09-26 21:50:00.000000000
+0200
@@ -231,6 +231,10 @@
if self.incset_list: return self.incset_list[-1]
else: return self.fullset
+ def get_first(self):
+ """Return first BackupSet in chain (ie the full backup)"""
+ return self.fullset
+
def __str__(self):
"""Return string representation, for testing purposes"""
set_schema = "%20s %30s %15s"
@@ -661,6 +665,18 @@
"""Return a list of chains older than time t"""
assert self.values_set
return filter(lambda c: c.end_time < t, self.all_backup_chains)
+
+ def get_last_full_backup(self):
+ """Return the time of the last full backup of the collection"""
+ assert self.values_set
+ # 1. Not sure if I count on the order of the chains
+ # To be on the safe side, find out the latest by looping through
+ # 2. Is there a nicer way to do that with a lambda function?
+ last = self.all_backup_chains[0]
+ for bc in self.all_backup_chains:
+ if bc.get_first().time > last.get_first().time:
+ last = bc
+ return last.get_first().time
def get_older_than(self, t):
"""Returns a list of backup sets older than the given time t
diff -ru --ignore-matching-lines '^#!' duplicity-0.4.3.org/src/commandline.py
duplicity-0.4.3-oliv/src/commandline.py
--- duplicity-0.4.3.org/src/commandline.py 2007-08-20 17:19:25.000000000
+0200
+++ duplicity-0.4.3-oliv/src/commandline.py 2007-09-26 22:54:02.000000000
+0200
@@ -57,6 +57,7 @@
"ftp-passive",
"ftp-regular",
"full",
+ "full-if-older-than=",
"gpg-options=",
"help",
"incremental",
@@ -116,6 +117,8 @@
select_files.append(sys.stdin)
elif opt == "-f" or opt == "--full":
full_backup = 1
+ elif opt == "--full-if-older-than":
+ globals.full_force_time = dup_time.genstrtotime(arg)
elif opt == "--force":
globals.force = 1
elif opt == "--ftp-passive":
@@ -217,6 +220,7 @@
--exclude-regexp <regexp>
--file-to-restore <path>
-f, --full
+ --full-if-older-than
--force
--ftp-passive
--ftp-regular
diff -ru --ignore-matching-lines '^#!' duplicity-0.4.3.org/src/globals.py
duplicity-0.4.3-oliv/src/globals.py
--- duplicity-0.4.3.org/src/globals.py 2007-08-20 17:19:25.000000000 +0200
+++ duplicity-0.4.3-oliv/src/globals.py 2007-09-26 21:58:56.000000000 +0200
@@ -80,6 +80,10 @@
# If set, use short (< 30 char) filenames for all the remote files.
short_filenames = 0
+# If set, forces a full backup if the last full backup is older than
+# the time specified
+full_force_time = None
+
# Used to confirm certain destructive operations like deleting old
# files.
force = None