~ubuntu-branches/ubuntu/natty/duplicity/natty-updates

« back to all changes in this revision

Viewing changes to duplicity

  • Committer: Bazaar Package Importer
  • Author(s): Steinar H. Gunderson
  • Date: 2006-11-11 13:32:07 UTC
  • mfrom: (2.1.3 feisty)
  • Revision ID: james.westby@ubuntu.com-20061111133207-9gizpeda242fwmtr
Tags: 0.4.2-10.1
Switch back to python 2.4, as python-central can apparently no longer cope
with 2.3, and 2.4 seems to work ok now; patch from Joey Hess.
(Closes: #396158)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
# duplicity -- Encrypted bandwidth efficient backup
3
 
# Version 0.4.1 released September 29, 2002
 
3
# Version 0.4.2 released September 29, 2002
4
4
#
5
5
# Copyright (C) 2002 Ben Escoto <bescoto@stanford.edu>
6
6
#
37
37
def get_passphrase():
38
38
        """Get passphrase from environment or, failing that, from user"""
39
39
        try: return os.environ['PASSPHRASE']
40
 
        except KeyError:
41
 
                if globals.encryption:
42
 
                        log.Log("PASSPHRASE variable not set, asking user.", 5)
43
 
                        return getpass.getpass("GnuPG passphrase: ")
44
 
                else: return "" # assume we don't need passphrase
 
40
        except KeyError: pass
 
41
        if not globals.encryption: return "" # assume we don't need passphrase
45
42
 
 
43
        log.Log("PASSPHRASE variable not set, asking user.", 5)
 
44
        while 1:
 
45
                pass1 = getpass.getpass("GnuPG passphrase: ")
 
46
                pass2 = getpass.getpass("Retype to confirm: ")
 
47
                if pass1 == pass2: return pass1
 
48
                print "First and second passphrases do not match!  Please try again."
46
49
 
47
50
def write_multivol(backup_type, tarblock_iter, backend):
48
51
        """Encrypt volumes of tarblock_iter and write to backend
119
122
 
120
123
        """
121
124
        assert sig_type == "full-sig" or sig_type == "new-sig"
 
125
 
 
126
        sig_filename = file_naming.get(sig_type, encrypted = globals.encryption,
 
127
                                                                   gzipped = not globals.encryption)
 
128
        fh = globals.backend.get_fileobj_write(sig_filename)
 
129
 
 
130
        # by MDR.  This was changed to use addfilehandle so we get both
 
131
        # remote and local sig files
122
132
        if globals.archive_dir:
123
 
                sig_filename = file_naming.get(sig_type, gzipped = 1)
124
 
                return dup_temp.get_fileobj_duppath(globals.archive_dir, sig_filename)
125
 
        else:
126
 
                sig_filename = file_naming.get(sig_type,
127
 
                         encrypted = globals.encryption, gzipped = not globals.encryption)
128
 
                return globals.backend.get_fileobj_write(sig_filename)
 
133
                local_sig_filename = file_naming.get(sig_type, gzipped = 1)
 
134
                fh.addfilehandle(dup_temp.get_fileobj_duppath(globals.archive_dir,
 
135
                                                                                                          local_sig_filename))
 
136
        return fh
129
137
 
130
138
def full_backup(col_stats):
131
139
        """Do full backup of directory to backend, using archive_dir"""
300
308
                                 "deleted because newer sets depend on them." %
301
309
                                 set_times_str(req_list))
302
310
 
 
311
        if (col_stats.matched_chain_pair and
 
312
                col_stats.matched_chain_pair[1].end_time < globals.remove_time):
 
313
                log.Warn("Current active backup chain is older than specified time.\n"
 
314
                         "However, it will not be deleted.  To remove all your backups,\n"
 
315
                                 "manually purge the repository.")
 
316
 
303
317
        setlist = col_stats.get_older_than(globals.remove_time)
304
318
        if not setlist:
305
319
                log.Warn("No old backup sets found, nothing deleted.")
312
326
                                          set_times_str(setlist), 3)
313
327
                setlist.reverse() # save oldest for last
314
328
                for set in setlist: set.delete()
 
329
                col_stats.set_values(sig_chain_warning = None).cleanup_signatures()
315
330
        else:
316
331
                if len(setlist) > 1:
317
332
                        log.Warn("Found old backup sets at the following times:")