1
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
3
# Copyright 2002 Ben Escoto <ben@emerose.org>
4
# Copyright 2007 Kenneth Loafman <kenneth@loafman.com>
6
# This file is part of duplicity.
8
# Duplicity is free software; you can redistribute it and/or modify it
9
# under the terms of the GNU General Public License as published by the
10
# Free Software Foundation; either version 2 of the License, or (at your
11
# option) any later version.
13
# Duplicity is distributed in the hope that it will be useful, but
14
# WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
# General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with duplicity; if not, write to the Free Software Foundation,
20
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
from duplicity import path
26
from . import CmdError, FunctionalTestCase
29
class ReplicateTest(FunctionalTestCase):
31
Test backup/replicate/restore using duplicity binary
34
def runtest(self, dirlist, backup_options=[], replicate_options=[], restore_options=[]):
35
# Back up directories to local backend
37
self.backup(u"full", dirlist[0], current_time=current_time,
38
options=backup_options)
39
for new_dir in dirlist[1:]:
40
current_time += 100000
41
self.backup(u"inc", new_dir, current_time=current_time,
42
options=backup_options)
44
# Replicate to other backend
45
source_url = self.backend_url
46
target_url = u"file://testfiles/replicate_out"
47
self.run_duplicity(options=[u"replicate"] +
48
replicate_options + [source_url, target_url])
50
self.backend_url = target_url
52
# Restore each and compare them
53
for i in range(len(dirlist)):
55
current_time = 100000 * (i + 1)
56
self.restore(time=current_time, options=restore_options)
57
self.check_same(dirname, u"testfiles/restore_out")
59
time=current_time, options=restore_options)
61
def check_same(self, filename1, filename2):
62
"""Verify two filenames are the same"""
63
path1, path2 = path.Path(filename1), path.Path(filename2)
64
assert path1.compare_recursive(path2, verbose=1)
66
def test_replicate(self):
67
"""Test replication"""
68
self.runtest([u"testfiles/dir1", u"testfiles/dir2"])
70
def test_replicate_noencryption(self):
71
"""Test replication with decryption"""
72
self.runtest([u"testfiles/dir1", u"testfiles/dir2"],
73
replicate_options=[u"--no-encryption"])
75
def test_replicate_asym(self):
76
"""Test replication with reencryption"""
77
asym_options = [u"--encrypt-key", self.encrypt_key1]
78
self.runtest([u"testfiles/dir1", u"testfiles/dir2"],
79
replicate_options=asym_options, restore_options=asym_options)