AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1123058
Accepted
Hamish Downer
Hamish Downer
Asked: 2019-03-05 13:21:44 +0800 CST2019-03-05 13:21:44 +0800 CST 2019-03-05 13:21:44 +0800 CST

当所有 sigtar 和大多数清单文件丢失时提取未加密的重复备份

  • 772

我正在尝试从旧的重复备份中提取备份(由 ubuntu gui 完成,我相信它是 deja-dup)。

我从一个垂死的硬盘上复制了所有我能做的东西。我有

  • 很多difftar.gz文件——一些 2014 年和一些 2016 年。
  • 2014 年的一个.manifest文件。
  • 没有sigtar.gz文件

备份未加密 - 我解压缩了一个difftar.gz文件并在十六进制编辑器中检查它,我可以看到很多纯文本。

运行一些命令:

% duplicity --no-encryption --ignore-errors collection-status file:///home/hamish/poonbackup2014
Running in 'ignore errors' mode due to --ignore-errors; please re-consider if this was not intended
Last full backup date: Mon Sep 15 19:37:44 2014
Collection Status
-----------------
Connecting with backend: BackendWrapper
Archive directory: /home/hamish/.cache/duplicity/c34b5c3ae7d763a715fd062ec5f49baa

Found 1 secondary backup chain.
Secondary chain 1 of 1:
-------------------------
Chain start time: Mon Sep 15 19:37:44 2014
Chain end time: Mon Sep 15 19:37:44 2014
Number of contained backup sets: 1
Total number of contained volumes: 2063
 Type of backup set:                            Time:   Number of volumes:
                Full         Mon Sep 15 19:37:44 2014              2063
-------------------------

No backup chains with active signatures found
No orphaned or incomplete backup sets found.



% duplicity --no-encryption --ignore-errors collection-status file:///home/hamish/poonbackup2016
Running in 'ignore errors' mode due to --ignore-errors; please re-consider if this was not intended
Warning, found incomplete backup sets, probably left from aborted session
Last full backup date: none
Collection Status
-----------------
Connecting with backend: BackendWrapper
Archive directory: /home/hamish/.cache/duplicity/37e66337a462669832db8b2b852f9c6f

Found 0 secondary backup chains.
No backup chains with active signatures found
Also found 0 backup sets not part of any chain,
and 2 incomplete backup sets.
These may be deleted by running duplicity with the "cleanup" command.


% duplicity --no-encryption --ignore-errors list-current-files file:///home/hamish/poonbackup2014
Running in 'ignore errors' mode due to --ignore-errors; please re-consider if this was not intended
Synchronising remote metadata to local cache...
Deleting local /home/hamish/.cache/duplicity/f152114ed2326b0ba48e42e6ec0a23d6/duplicity-full.20140915T183744Z.manifest (not authoritative at backend).
Last full backup date: none
Traceback (innermost last):
  File "/usr/bin/duplicity", line 1555, in <module>
    with_tempdir(main)
  File "/usr/bin/duplicity", line 1541, in with_tempdir
    fn()
  File "/usr/bin/duplicity", line 1393, in main
    do_backup(action)
  File "/usr/bin/duplicity", line 1476, in do_backup
    list_current(col_stats)
  File "/usr/bin/duplicity", line 702, in list_current
    sig_chain = col_stats.get_signature_chain_at_time(time)
  File "/usr/lib/python2.7/dist-packages/duplicity/collections.py", line 998, in get_signature_chain_at_time
    raise CollectionsError("No signature chains found")
 CollectionsError: No signature chains found

假设我无法从原始硬盘驱动器中提取更多文件,我是否可以选择提取文件?

我对提取照片最感兴趣——如果我可以提取一个没有名称或文件元数据的照片文件,那么这将是一个胜利。

backup deja-dup duplicity restore
  • 2 2 个回答
  • 1467 Views

2 个回答

  • Voted
  1. ede
    2019-03-07T03:03:08+08:002019-03-07T03:03:08+08:00

    收集状态在 file:///home/hamish/poonbackup2014 中找到一个链。所以理论上你应该能够恢复整个备份。仅需要签名来恢复单个文件/文件夹或列出内容。

    ..ede/duply.net

    • 1
  2. Best Answer
    Hamish Downer
    2019-03-11T13:41:27+08:002019-03-11T13:41:27+08:00

    我总体上遵循了此答案中的指南,但我想扩展一些要点:

    全面的

    这些difftar.gz文件都是普通tar.gz文件,没有加密。如果您将它们全部解压缩,它们会将其内容放入文件结构中。顶层有两个目录:

    • snapshot/- 这包含普通文件,但在我的情况下,它有一个(非常)我关心的文件的一小部分 - 我想要恢复的 100 GB 中的大约 100 MB。
    • multivol_snapshot/- 这包含每个普通文件的目录。在每个目录中都有一组文件,文件名只有一个数字 - 1, 2, ... 文件大小似乎总是 64 kB(当然最后一个除外)。您可以手动将文件集中在一起,这对于少量文件来说是合理的。不过我有很多。

    打开包装

    首先,我需要解压缩所有 tar gz 文件:

    for f in duplicity-full.*.difftar.gz; do echo "$f"; tar xf "$f"; done
    

    重建

    上面喜欢的答案有一个shell one liner,但这会创建许多content与原始内容混合命名的文件。我想重新创建文件系统。所以我写了下面的python脚本,它有2个参数:

    • multivol_snapshot/包含要恢复的位的目录
    • 将恢复的文件放入其中的目录。

    它将递归地遍历所有内容并重新创建文件。只要您拥有所需的所有块,它就可以正常工作...

    #!/usr/bin/env python3
    import argparse
    from pathlib import Path
    import shutil
    import sys
    
    
    class FileReconstructor():
    
        def __init__(self, unpacked_dir, restore_dir):
            self.unpacked_path = Path(unpacked_dir).resolve()
            self.restore_path = Path(restore_dir).resolve()
    
        def reconstruct_files(self):
            for leaf_dir in self.walk_unpacked_leaf_dirs():
                target_path = self.target_path(leaf_dir)
                target_path.parent.mkdir(parents=True, exist_ok=True)
                with target_path.open('wb') as target_file:
                    self.copy_file_parts_to(target_file, leaf_dir)
    
        def copy_file_parts_to(self, target_file, leaf_dir):
            file_parts = sorted(leaf_dir.iterdir(), key=lambda x: int(x.name))
            for file_part in file_parts:
                with file_part.open('rb') as source_file:
                    shutil.copyfileobj(source_file, target_file)
    
        def walk_unpacked_leaf_dirs(self):
            """
            based on the assumption that all leaf files are named as numbers
            """
            seen_dirs = set()
            for path in self.unpacked_path.rglob('*'):
                if path.is_file():
                    if path.parent not in seen_dirs:
                        seen_dirs.add(path.parent)
                        yield path.parent
    
        def target_path(self, leaf_dir_path):
            return self.restore_path / leaf_dir_path.relative_to(self.unpacked_path)
    
    
    def parse_args(argv):
        parser = argparse.ArgumentParser()
        parser.add_argument(
            'unpacked_dir',
            help='The directory with the unpacked tar files',
        )
        parser.add_argument(
            'restore_dir',
            help='The directory to restore files into',
        )
        return parser.parse_args(argv)
    
    
    def main(argv):
        args = parse_args(argv)
        reconstuctor = FileReconstructor(args.unpacked_dir, args.restore_dir)
        return reconstuctor.reconstruct_files()
    
    
    if __name__ == '__main__':
        sys.exit(main(sys.argv[1:]))
    
    • 1

相关问题

  • NTFS 备份映像不会挂载

  • 如何备份/恢复我的 Empathy 日志?

  • 如何将 Ubuntu 放在非闪存外部 USB 硬盘驱动器上?

  • 备份工具比较

  • 如何使文件夹与外部 USB 硬盘保持同步?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve