duplicity-talk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Duplicity-talk] Patch introducing --full-if-older-than


From: Olivier Croquette
Subject: Re: [Duplicity-talk] Patch introducing --full-if-older-than
Date: Thu, 27 Sep 2007 00:09:13 +0200
User-agent: Thunderbird 2.0.0.4 (Macintosh/20070604)


Here is an updated version of the patch which avoids an exception in case the collection is empty.

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.
Only in duplicity-0.4.3-oliv/src: _librsync.so
Only in duplicity-0.4.3-oliv/src: backends.py.org
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-27 00:00:54.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, 
or 0"""
+               assert self.values_set
+               # Is there a nicer way to do that with a lambda function?
+               if len(self.all_backup_chains) == 0:
+                       return 0
+               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
Only in duplicity-0.4.3-oliv/src: collections.py.1
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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]