Product SiteDocumentation Site

9.10. 备份

Many programs exist, such as amanda, bacula, BackupPC. Those are client/server system featuring many options, whose configuration is rather difficult. Some of them provide user-friendly web interfaces to mitigate this. But Debian contains dozens of other backup software covering all possible use cases, as you can easily confirm with apt-cache search backup.
本章节并没有详细介绍这些工具,而是介绍 Falcot Corp (本书中虚构的公司)管理员们确定备份策略时的思路。
在 Falcot Corp公司,备份有两个目的:恢复被误删的文件,迅速恢复硬盘损坏的电脑。

9.10.1. 使用 rsync备份

Backups on tape having been deemed too slow and costly, data will be backed up on hard drives on a dedicated server, on which the use of software RAID (see 第 12.1.1 节 “软 RAID”) will protect the data from hard drive failure. Desktop computers are not backed up individually, but users are advised that their personal account on their department's file server will be backed up. The rsync command (from the package of the same name) is used daily to back up these different servers.
有限的硬盘空间限制了每天完全备份数据。由此,rsync 命令对之前备份的内容使用硬链接,这样可以避免使用过多的硬盘空间。 然后rsync 进程只覆盖上次备份后修改过的文件。通过这种机制,大量的备份只占用小的磁盘空间。所有的备份会立即生效并且可以读写(例如,在共享网络上的不同目录),可以迅速比较两个不同日期的文件。
这种备份机制可以通过 dirvish 程序执行。使用备份存储空间(“空”的),放置有时间戳的备份文件集(这些文件集在dirvish 文档中被成为“vaults”)。
主要配置在 /etc/dirvish/master.conf 文件中。它定义了备份存储空间的位置,要管理的“vaults”,和备份超期的默认值。配置的其他部分在 bank/vault/dirvish/default.conf 文件中,包含对应文件集的特殊配置。

例 9.3. The /etc/dirvish/master.conf file

    root    22:00
expire-default: +15 days
    *   *     *   *         1    +3 months
    *   *     1-7 *         1    +1 year
    *   *     1-7 1,4,7,10  1
The bank setting indicates the directory in which the backups are stored. The exclude setting allows you to indicate files (or file types) to exclude from the backup. The Runall is a list of file sets to backup with a time-stamp for each set, which allows you to assign the correct date to the copy, in case the backup is not triggered at precisely the assigned time. You have to indicate a time just before the actual execution time (which is, by default, 10:04 pm in Debian, according to /etc/cron.d/dirvish). Finally, the expire-default and expire-rule settings define the expiration policy for backups. The above example keeps forever backups that are generated on the first Sunday of each quarter, deletes after one year those from the first Sunday of each month, and after 3 months those from other Sundays. Other daily backups are kept for 15 days. The order of the rules does matter, Dirvish uses the last matching rule, or the expire-default one if no other expire-rule matches.

例 9.4. /backup/root/dirvish/default.conf 文件

tree: /
xdev: 1
index: gzip
image-default: %Y%m%d
上面的例子中指明了要备份的文件集:这些文件在机器 上(对本地数据备份,只需指明本地机器 hostname),主要是在根目录下(tree: /),除了在 exclude中列出的文件。备份仅限于一个文件系统中的内容(xdev: 1)。不包含其他挂载点的文件。产生保存文件的索引(index: gzip),镜像根据当前日期进行命名(image-default: %Y%m%d)。
有许多可用选项,都记录在 dirvish.conf(5) 手册中。一旦这些配置文件设定好后,必须要使用dirvish --vault vault --init 命令来初始化每个文件集。此后每天在删除过期备份之后,就会自动唤起 dirvish-runall 进行备份。

9.10.2. 不使用备份恢复系统

Desktop computers, which are not backed up, will be easy to reinstall from custom DVD-ROMs prepared with Simple-CDD (see 第 12.3.3 节 “Simple-CDD: The All-In-One Solution”). Since this performs an installation from scratch, it loses any customization that can have been made after the initial installation. This is fine since the systems are all hooked to a central LDAP directory for accounts and most desktop applications are preconfigured thanks to dconf (see 第 13.3.1 节 “GNOME” for more information about this).
The Falcot Corp administrators are aware of the limits in their backup policy. Since they can't protect the backup server as well as a tape in a fireproof safe, they have installed it in a separate room so that a disaster such as a fire in the server room won't destroy backups along with everything else. Furthermore, they do an incremental backup on DVD-ROM once per week — only files that have been modified since the last backup are included.