Làm gì nếu bạn không thể phục hồi các tập tin
Michael Terry

Creative Commons Attribution-Share Alike 4.0 Unported License

Lê Trường An
https://launchpad.net/~truongan

# Khi mọi thứ trở nên xấu đi

Déjà Dup may fail. Maybe it crashes or gives you an error when you try to restore. When you really need your data back, the last thing you want do deal with is a bug. Consider filing a help request but in the meantime, here are some approaches to workaround a misbehaving Déjà Dup and get your data back.

Hỗ trợ kĩ thuật cho bạn. Nếu bạn vẫn còn thắc mắc, đừng ngần ngại đặt câu hỏi.

These instructions assume you are have a command line available. Open a Terminal window first.

# Restic or Duplicity?

Over time, Déjà Dup has used different backup tools under the covers. Originally, it used Duplicity. Nowadays, it uses Restic.

Your backup might be in either format, depending on when you created it.

Look in the folder where your backup is kept:

If the filenames all start with duplicity-, then it's a Duplicity backup. Read the Duplicity sections below.

If you see a config file and a few folders like keys, then it's a Restic backup. Read the Restic sections below.

# Restoring with Restic

On the assumption that Déjà Dup is just not working for you right now, let’s use the command line tool Restic that is used by Déjà Dup behind the scenes to back up and restore your files.

If you want more information about Restic than presented here, run restic --help.

Việc đầu tiên chúng ta thử đơn giản chỉ là phục hồi tất cả dữ liệu của bạn. Nếu các tập tin nằm trên ổ đĩa gắn ngoài được gắn kết vào /media/backup và bạn chọn mã hóa bản sao lưu, hãy thử:

    restic restore --repo=/media/backup --target=/tmp/restore latest

Nếu bạn không mã hóa bản sao lưu, thêm --insecure-no-password vào lệnh.

If you need to do more advanced debugging, read their troubleshooting guide.

# Phục hồi với Duplicity

On the assumption that Déjà Dup is just not working for you right now, let’s use the command line tool duplicity that is used by Déjà Dup behind the scenes to back up and restore your files.

If you want more information about Duplicity than presented here, read its online documentation.

Việc đầu tiên chúng ta thử đơn giản chỉ là phục hồi tất cả dữ liệu của bạn. Nếu các tập tin nằm trên ổ đĩa gắn ngoài được gắn kết vào /media/backup và bạn chọn mã hóa bản sao lưu, hãy thử:

    duplicity restore file:///media/backup /tmp/restore

Nếu bạn không mã hóa bản sao lưu, thêm --no-encryption vào lệnh.

## Other Storage Locations

If you backed up to a remote or cloud server, the syntax you use with Duplicity will be different than the external drive example above.

Read the Duplicity documentation for instructions on how to connect to your server, or try downloading all the Duplicity files yourself to a local folder and following the simpler example above.

## Restoring Duplicity Files by Hand

Thậm chí duplicity không hoạt động, hy vọng vẫn còn dù là nhỏ nhoi. Tập tin sao lưu khá phức tạp và không dễ đọc được. Nhưng nếu bạn đang tuyệt vọng, nó đáng để thử.

If you used a remote or cloud server to store your backup, first download all the duplicity files and place them in a folder on your computer. Then enter that folder in your terminal.

Duplicity stores your data in small chunks called volumes. Some volumes belong to the periodic ‘full’ or fresh backups and others to the ‘inc’ or incremental backups. Starting with a full backup set of volumes at volume 1, you’ll need to restore files volume by volume.

If you encrypted your backup, first you must decrypt the volume with gpg. Say you have duplicity-full.20110127T131352Z.vol1.difftar.gpg:

    gpg --output duplicity-full.20110127T131352Z.vol1.difftar --decrypt duplicity-full.20110127T131352Z.vol1.difftar.gpg

Or to do all at once (make sure you have plenty of space!):

    gpg --multifile --decrypt duplicity-full.20110127T131352Z.*.difftar.gpg

Now you have either a .difftar or a .difftar.gz volume (depending on whether you had to decrypt it or not). Use tar on whichever one you have to extract the individual patch files:

    tar xf duplicity-full.20110127T131352Z.vol1.difftar

Or again, to do all at once:

    for t in duplicity-full.20110127T131352Z.*.difftar; do tar xf $t; done

Now the patch files will be in multivolume_snapshot and snapshot folders. Each file that spanned multiple volumes will be in multivolume_snapshot. Let’s say you backed up /home/jane/essay.txt:

    cd multivolume_snapshot/home/jane/essay.txt
    cat * > essay.txt

To recover data from incremental backups, use rdiff to stitch the files together. See man rdiff for usage.