曦远 (DealiAxy)一份私人的文字刊物

StarBlog
返回文章列表折页手记阅读全文
个人数据保全计划

Personal Data Preservation Plan: How to Safely Back Up Data

Huh, using something like mc, that prehistoric file manager, to back up data and feeling smug about it? The way rsync does checksumming is barely passable. And then, to top it off, generating a sha256 manifest with such seriousness—do people actually still manually verify cold backups these days?

曦远 (DealiAxy)约 10 分钟
目录5 个章节

Introduction

Backup data can be both simple and complex.

The simplest way is using the cp command to directly copy files.

However, once there is a large amount of data to back up, things become more involved.

How to show progress? How to ensure the backed-up data is error-free?

There is still quite a bit to consider here.

Basic Idea

I plan to use the SSD originally prepared for QNAP to install PVE.

This drive contains some docker and QTS software; the data to back up is the docker data.

There are several methods:

  • rsync: rsync -a --info=progress2 /mnt/disk1/your-folder /mnt/disk2/
  • Midnight Commander (mc) (visual)

Using mc

I ultimately chose mc — it's user-friendly and simple.

After installing with sudo dnf install mc, open it in the terminal.

The left and right panels allow browsing different directories on the hard drive. Use Ctrl+T to select multiple files/directories, then press F5 to copy.

mc

Press Enter to start copying. The interface has a nice retro aesthetic, which feels quite appealing~

copy

Verify Data

After the copy is complete, verify the integrity of the data.

The simplest way is to use rsync.

rsync -avhn /path/to/src/ /path/to/target/

You will get output similar to this:

sending incremental file list

sent 426.77K bytes  received 2.90K bytes  859.33K bytes/sec
total size is 1.45G  speedup is 3,367.09 (DRY RUN)

sending incremental file list ➜ Only lists differences (specific files are not listed now → indicates no changes).

By default, rsync's dry-run verification determines whether two files are "the same" based on: whether the file size is consistent and whether the last modification timestamp is consistent.

If you want it to be more reliable, you can verify the MD5 and SHA of the files. Add the --checksum (or -c) parameter to the rsync command.

rsync -avhnc --info=progress2 /src/ /dst/
  • -c / --checksum: Compares the checksum of the content (not the timestamp, not the size).
  • This causes rsync to read all source and target file contents, calculate, and compare checksums. The precision is equivalent to MD5 verification, but it is smarter than md5sum (it can skip files that have already been compared).

The output after running the command will look something like this:

sending incremental file list
              0   0%    0.00kB/s    0:00:00 (xfr#0, to-chk=0/18633)   

sent 680.95K bytes  received 2.90K bytes  91.18K bytes/sec
total size is 1.45G  speedup is 2,115.56 (DRY RUN)

Let's interpret this output:

  • xfr#0: The actual number of files that need to be copied/replaced is 0.
  • to-chk=0/18633: A total of 18,633 files were compared, and all have been checked (0 remaining).
  • 0%, 0.00kB/s: This is because there is no actual data flow in dry-run mode, so the speed is displayed as zero.

Output sha256sum List

If you plan to archive, cold backup, or leave it untouched for a long time, you can optionally create a sha256sum list for long-term verification:

find /home/deali/Backups/projects -type f -exec sha256sum {} \; > backup-sha256.txt

You can verify it in the future like this:

sha256sum -c backup-sha256.txt

If the file path changes, you can replace it with the following command:

sed -i 's|/home/deali/Backups|/var/lib/vz/backups|g' project-sha256.txt

After running the verification, it will output the result for each file, for example:

/var/lib/vz/backups/softwares/navidrome/cache/images/af/e9/afe97c40758c021a2de1f781ab14d4d3fc30b244: OK

If everything is correct, no error messages will be output.

_EOF_

Personal Data Preservation Plan: How to Safely Back Up Data

本文作者:
程序设计实验室
版权声明:
本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!

相关文章

个人数据保全计划:部署joplin server笔记同步服务

在这个数据爆炸的时代,个人数据的价值愈发凸显,成为我们生活与工作中无可替代的重要资产。上一篇文章里,我介绍了从印象笔记迁移至 Joplin 的过程,这是我寻求数据自主掌控的关键一步。在探索同步方案时,我尝试了 OneDrive,原以为它能提供稳定高效的同步服务,可实际使用时却发现它对小文件缺乏优化,同步速度极慢,极大影响了使用体验。虽说目前还不确定是否存在数据丢失问题,但这样的效率实在难以满足我的

2025-02-02 · 个人数据保全计划 · 约 1 分钟

讨论

共 0 条

良言一句三冬暖,恶语伤人六月寒。

加载评论中…