Commit 175dfb75 authored by Michael Terry's avatar Michael Terry

first cut at bad-volume handling

parent 00b1c5f1
......@@ -91,6 +91,9 @@ public class Duplicity : Object
bool needs_root = false;
bool detected_encryption = false;
bool existing_encrypted = false;
string last_bad_volume;
uint bad_volume_count;
bool has_progress_total = false;
uint64 progress_total; // zero, unless we already know limit
......@@ -754,6 +757,7 @@ public class Duplicity : Object
protected static const int ERROR_RESTORE_DIR_NOT_FOUND = 19;
protected static const int ERROR_EXCEPTION = 30;
protected static const int ERROR_GPG = 31;
protected static const int ERROR_BAD_VOLUME = 44;
protected static const int ERROR_BACKEND = 50;
protected static const int ERROR_BACKEND_PERMISSION_DENIED = 51;
protected static const int ERROR_BACKEND_NOT_FOUND = 52;
......@@ -889,6 +893,27 @@ public class Duplicity : Object
return;
break;
case ERROR_BAD_VOLUME:
// A volume was detected to be corrupt/incomplete after uploading.
// We'll first try a restart because then duplicity will retry it.
// If it's still bad, we'll do a full cleanup and try again.
// If it's *still* bad, tell the user, but I'm not sure what they can
// do about it.
if (mode == Operation.Mode.BACKUP) {
var this_volume = firstline[2];
if (last_bad_volume != this_volume) {
bad_volume_count = 0;
last_bad_volume = this_volume;
}
if ((bad_volume_count == 0 && restart()) ||
(bad_volume_count == 1 && cleanup())) {
bad_volume_count += 1;
return;
}
}
break;
case ERROR_BACKEND_PERMISSION_DENIED:
if (firstline.length >= 5 && firstline[2] == "put") {
var file = make_file_obj(firstline[4]);
......
#!/usr/bin/env python
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 2; coding: utf-8 -*-
#
# This file is part of Déjà Dup.
# For copyright information, see AUTHORS.
#
# Déjà Dup is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Déjà Dup is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Déjà Dup. If not, see <http://www.gnu.org/licenses/>.
import sys
scriptdir=sys.path[0]
sys.path.insert(0, scriptdir+'/..')
import base
import os
import tempfile
if not base.dup_meets_version(0, 6, 16):
base.skip()
# Set up our duplicity wrapper to be called by deja-dup
os.environ['PATH'] = os.path.join(scriptdir, 'bad-volume-bin') + ":" + os.environ['PATH']
def set_skip_volumes(vols):
(fd, name) = tempfile.mkstemp()
f = os.fdopen(fd, 'wb')
f.write(' '.join([str(x) for x in vols]))
f.close()
os.environ['DEJA_DUP_TEST_SKIP_FILE'] = name
base.cleanup_dirs.append(name)
def test():
base.setup()
set_skip_volumes([3, 3, 3])
base.backup_simple(backend='file', encrypt=False, includes=['/usr/bin'],
error='lblBlarg')
def test():
base.setup()
set_skip_volumes([1, 2, 3, 4])
base.backup_simple(backend='file', encrypt=False, includes=['/usr/bin'])
base.run(test)
#!/usr/bin/env python
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 2; coding: utf-8 -*-
#
# This file is part of Déjà Dup.
# For copyright information, see AUTHORS.
#
# Déjà Dup is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Déjà Dup is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Déjà Dup. If not, see <http://www.gnu.org/licenses/>.
# This file acts like a duplicity wrapper.
# The environment variable DEJA_DUP_TEST_SKIP_FILE points to a file containing
# numbers of volumes to skip.
import os
import sys
import subprocess
# Drop the PATH override that pointed to this script
os.environ['PATH'] = os.environ['PATH'].split(':', 1)[-1]
# Read the skip file to see what we should skip
f = open(os.environ['DEJA_DUP_TEST_SKIP_FILE'])
all_volumes = f.read().split()
f.close()
extra_args = []
if all_volumes:
f = open(os.environ['DEJA_DUP_TEST_SKIP_FILE'], 'wb')
f.write(' '.join(all_volumes[1:]))
f.close()
extra_args = ['--skip-volume', all_volumes[0]]
subprocess.call(['duplicity'] + sys.argv[1:] + extra_args)
......@@ -221,7 +221,7 @@ def start_deja_dup(args=[], executable='deja-dup', waitfor='frmBackup', debug=Fa
cmd = ['gnome-terminal', '-x', 'gdb', '-ex', 'run'] + cmd
# FIXME gtk3/gail3 seem problematic with always-malloc
#environ['G_SLICE'] = 'always-malloc,debug-blocks'
environ['G_SLICE'] = 'debug-blocks'
#environ['G_SLICE'] = 'debug-blocks'
environ['G_DEBUG'] = 'gc-friendly' if not environ.get('G_DEBUG') else environ['G_DEBUG'] + ',gc-friendly'
subprocess.Popen(cmd)
if waitfor is not None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment