Difference between revisions of "System backup (简体中文)"

From ArchWiki
Jump to navigation Jump to search
(create page)
 
(添加中文标题)
Line 13: Line 13:
 
{{Related articles end}}
 
{{Related articles end}}
  
It is important to regularly backup system and user data stored for example in {{ic|/etc}}, {{ic|/home}}, {{ic|/var}} and for server installations, also {{ic|/srv}}.
+
常规性的备份系统和用户数据是非常重要的,比如说 {{ic|/etc}}, {{ic|/home}}, {{ic|/var}} 这些目录。如果是服务器还有 {{ic|/srv}}.
  
== Using Btrfs snapshots ==
+
== 使用 Btrfs snapshots ==
  
 
See [[Btrfs#Snapshots]] and [[Snapper]].
 
See [[Btrfs#Snapshots]] and [[Snapper]].
  
== Using LVM snapshots ==
+
== 使用 LVM snapshots ==
  
 
See [[LVM#Snapshots]] and [[Create root filesystem snapshots with LVM]].
 
See [[LVM#Snapshots]] and [[Create root filesystem snapshots with LVM]].
  
== Using rsync ==
+
== 使用 rsync ==
  
 
See [[rsync#As a backup utility]].
 
See [[rsync#As a backup utility]].
  
== Using tar ==
+
== 使用 tar ==
  
 
See [[Full system backup with tar]].
 
See [[Full system backup with tar]].
  
== Using SquashFS ==
+
== 使用 SquashFS ==
  
 
See [[Full system backup with SquashFS]].
 
See [[Full system backup with SquashFS]].
  
== Bootable backup ==
+
== 能够启动(boot)的备份 ==
  
 
Having a bootable backup can be useful in case the filesystem becomes corrupt or if an update breaks the system. The backup can also be used as a test bed for updates, with the ''testing'' repo enabled, etc. If you transferred the system to a different partition or drive and you want to boot it, the process is as simple as updating the backup's {{ic|/etc/fstab}} and your bootloader's configuration file.
 
Having a bootable backup can be useful in case the filesystem becomes corrupt or if an update breaks the system. The backup can also be used as a test bed for updates, with the ''testing'' repo enabled, etc. If you transferred the system to a different partition or drive and you want to boot it, the process is as simple as updating the backup's {{ic|/etc/fstab}} and your bootloader's configuration file.
Line 41: Line 41:
 
This section assumes that you backed up the system to another drive or partition, that your current bootloader is working fine, and that you want to boot from the backup as well.
 
This section assumes that you backed up the system to another drive or partition, that your current bootloader is working fine, and that you want to boot from the backup as well.
  
=== Update the fstab ===
+
=== 更新 fstab ===
  
 
Without rebooting, edit the backup's [[fstab]] by commenting out or removing any existing entries. Add one entry for the partition containing the backup like the example here:
 
Without rebooting, edit the backup's [[fstab]] by commenting out or removing any existing entries. Add one entry for the partition containing the backup like the example here:
Line 49: Line 49:
 
Remember to use the proper device name and filesystem type.
 
Remember to use the proper device name and filesystem type.
  
=== Update the bootloader's configuration file ===
+
=== 更新引导程序的配置文件 ===
  
 
For [[Syslinux]], all you need to do is duplicate the current entry, except pointing to a different drive or partition.
 
For [[Syslinux]], all you need to do is duplicate the current entry, except pointing to a different drive or partition.
Line 65: Line 65:
 
  # grep UUID= /boot/grub/grub.cfg
 
  # grep UUID= /boot/grub/grub.cfg
  
=== First boot ===
+
=== 第一次启动 ===
  
 
Reboot the computer and select the right entry in the bootloader. This will load the system for the first time. All peripherals should be detected and the empty folders in {{ic|/}} will be populated.
 
Reboot the computer and select the right entry in the bootloader. This will load the system for the first time. All peripherals should be detected and the empty folders in {{ic|/}} will be populated.
  
 
Now you can re-edit {{ic|/etc/fstab}} to add the previously removed partitions and mount points.
 
Now you can re-edit {{ic|/etc/fstab}} to add the previously removed partitions and mount points.

Revision as of 05:34, 30 January 2019

常规性的备份系统和用户数据是非常重要的,比如说 /etc, /home, /var 这些目录。如果是服务器还有 /srv.

使用 Btrfs snapshots

See Btrfs#Snapshots and Snapper.

使用 LVM snapshots

See LVM#Snapshots and Create root filesystem snapshots with LVM.

使用 rsync

See rsync#As a backup utility.

使用 tar

See Full system backup with tar.

使用 SquashFS

See Full system backup with SquashFS.

能够启动(boot)的备份

Having a bootable backup can be useful in case the filesystem becomes corrupt or if an update breaks the system. The backup can also be used as a test bed for updates, with the testing repo enabled, etc. If you transferred the system to a different partition or drive and you want to boot it, the process is as simple as updating the backup's /etc/fstab and your bootloader's configuration file.

This section assumes that you backed up the system to another drive or partition, that your current bootloader is working fine, and that you want to boot from the backup as well.

更新 fstab

Without rebooting, edit the backup's fstab by commenting out or removing any existing entries. Add one entry for the partition containing the backup like the example here:

/dev/sdaX    /             ext4      defaults                 0   1

Remember to use the proper device name and filesystem type.

更新引导程序的配置文件

For Syslinux, all you need to do is duplicate the current entry, except pointing to a different drive or partition.

Tip: Instead of editing syslinux.cfg, you can also temporarily edit the menu during boot. When the menu shows up, press the Tab key and change the relevant entries. Partitions are counted from one, drives are counted from zero.

For GRUB, it is recommended that you automatically re-generate the main configuration file. If you want to freshly install all grub files to somewhere other than /boot, such as /mnt/newroot/boot, use the --boot-directory flag.

Also verify the new menu entry in /boot/grub/grub.cfg. Make sure the UUID is matching the new partition, otherwise it could still boot the old system. Find the UUID of a partition with lsblk:

$ lsblk -no NAME,UUID /dev/sdb3

where you substitute the desired partition for /dev/sdb3. To list the UUIDs of partitions grub thinks it can boot, use grep:

# grep UUID= /boot/grub/grub.cfg

第一次启动

Reboot the computer and select the right entry in the bootloader. This will load the system for the first time. All peripherals should be detected and the empty folders in / will be populated.

Now you can re-edit /etc/fstab to add the previously removed partitions and mount points.