システムバックアップ
関連記事
例えば /etc
, /home
, /root
, /var
, サーバーの場合は /srv
に保存されているシステムとユーザーのデータを定期的にバックアップすることが重要です。
目次
Btrfs のスナップショットを利用する
こちらを参照 Btrfs#スナップショット, システムバックアップ#スナップショットと/bootパーティション, それと Snapper
LVM のスナップショットを利用する
こちらを参照 LVM#スナップショット, LVM によるルートファイルシステムのスナップショット作成, それと システムバックアップ#スナップショットと/bootパーティション
rsync を利用する
こちらを参照 rsync によるフルシステムバックアップ
tar を利用する
こちらを参照 Tar によるフルシステムバックアップ
SquashFS を利用する
Bootable backup
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.
Update the 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.
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 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/sdXY
where /dev/sdXY
is the desired partition (e.g. /dev/sdb3
). To list the UUIDs of partitions GRUB thinks it can boot, use grep:
# 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 /
will be populated.
Now you can re-edit /etc/fstab
to add the previously removed partitions and mount points.
Snapshots and /boot partition
If your file system supports snapshots (e.g., LVM or Btrfs), these will most likely exclude the /boot
partition or ESP.
You can copy the boot partition automatically on a kernel update to your root
partition with a pacman hook (make sure the hook file is owned by root):
/etc/pacman.d/hooks/50-bootbackup.hook
[Trigger] Operation = Upgrade Operation = Install Operation = Remove Type = Path Target = usr/lib/modules/*/vmlinuz [Action] Depends = rsync Description = Backing up /boot... When = PostTransaction Exec = /usr/bin/rsync -a --delete /boot /.bootbackup