如何备份Linux文件系统?

Linux is a stable operating system. There is a rare strong operating system foundation. But critical errors have occurs rarely too. Or they may be some hardware-related problems. If your Linux system got down where your database resides what will happen? If you have a backup is not so big problem. We can simply recover from a backup. What if we have no backup?

Linux是稳定的操作系统。 有一个罕见的强大操作系统基础。 但是严重错误也很少发生。 或者它们可能是一些与硬件相关的问题。 如果您Linux系统崩溃了,数据库将驻留在哪里? 如果您有备份不是那么大的问题。 我们可以简单地从备份中恢复。 如果我们没有备份怎么办?

dd备份分区 (Backup Partition With dd)

dd is a very useful tool. It is simple operation is convert and copy but this function can be used for different purposes like back up.

dd是一个非常有用的工具。 转换和复制是简单的操作,但是此功能可用于不同目的,例如备份。

$ sudo dd if=/dev/vda1 of=/mnt/backup.dd
  • dd operation requires root privileges so we use sudo

    dd操作需要root特权,因此我们使用sudo

  • if=/dev/vda1 is input file where vda disk first partition

    if = / dev / vda1是输入文件,其中vda磁盘是第一个分区

  • of=/mnt/backup.dd  is out output file where we create a new file named backup.dd

    of = / mnt / backup.dd是输出文件,我们在其中创建一个名为backup.dd的新文件

This operation will take some time because the whole partition will be backed up.

此操作将花费一些时间,因为将备份整个分区。

带有dd的备份引导加载程序(MBR) (Backup Boot Loader (MBR) with dd)

We can back up our boot loader sectors easily with dd. As we know dd work in the raw mode so it only knows sectors and segments and Master Boot Records resides in the first 512 byte we can use dd. This backup can be useful if we will install Windows or other operating-system other partitions and do not want to lose our MBR

我们可以使用dd轻松备份引导加载程序扇区。 我们知道dd在原始模式下工作,因此它仅知道扇区和段,并且主引导记录位于前512个字节中,因此我们可以使用dd。 如果我们将安装Windows或其他操作系统的其他分区并且不想丢失MBR,则此备份很有用。

$ dd if=/dev/sda of=/mnt/mbr.bak bs=512 count=1
  • if=/dev/sda is disk where MBR resides

    if = / dev / sda是MBR所在的磁盘

  • of=/mnt/mbr.bak is our backup file

    of = / mnt / mbr.bak是我们的备份文件

  • bs=512 provides how many bytes will be read at once

    bs = 512提供了一次读取多少字节

  • count=1 specifies how many time will the read operation is done

    count = 1指定将执行多少次读取操作

With bs and count parameter we want to read 512 bytes for one time

使用bs和count参数,我们希望一次读取512个字节

LEARN MORE  Linux dd Command To Backup with Examples
了解更多Linux dd命令以进行示例备份

We can recover our backup like below

我们可以像下面那样恢复备份

$ dd if=/mnt/mbr.bak of=/dev/vda bs=512 count=1

As you see we have changed the input and output files.

如您所见,我们已经更改了输入和输出文件。

一些技巧 (Some Tips)

  • To continue even copy operation has error we can provide conf=noerror parameter.

    要继续进行复制操作甚至会出错,我们可以提供conf = noerror参数。

  • To sync without buffering data with dd sync operation can be used.

    可以使用不带数据同步的dd同步操作进行同步

翻译自: https://www.poftut.com/backup-linux-file-system/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值