Linux系统之备份数据

System Backup and Recovery

Rsync

Rsync is the directory backup and transfer tool for Linux. It is installed by default in Ubuntu. It can provide any type of backup, and options are extensive. Several GUI frontends for Rsync are listed here.

GRsync

GRsync is a GTK-based GUI front-end for Rsync. Install:

sudo apt-get install grsync

Bacula

Bacula is the most widely-used GTK-based open source (GPL-licensed) network backup utility that is used in both server and desktop installations. A catalogue of backups can be maintained using MySQL, PostgreSQL, or SQLite. For more info see the Ubuntu documentation. Both text-based and GUI frontends are available. Install the MySQL version:

sudo apt-get install bacula

SBackup

SBackup is a simple backup and restore utility for the GTK-desktop. Install:

sudo apt-get install sbackup

Keep (Backup and Recovery)

Keep is a QT/KDE based backup utility used in previous versions of Ubuntu. It is no longer maintained and is not included in Ubuntu by default. Install:

sudo apt-get install keep

Run:

  • Menu -> Applications -> System Tools -> Keep (Backup System)
  • Backup:
Click "Add a Directory to Backup"
Select directories you wish to backup
Select a location to place the backup
Set how often you wish the backups to take place, and how long to keep them
Click "Backup Now"
Select the directory groups you wish to backup.
  • Recover:
Click "Restore a Backup"
Select the directory groups you wish to restore.

Partimage (Partition backup)

Partimage is a free open-source utility to back up an entire partition into an .iso image. It can be used across a network, as well. Install and run:

sudo apt-get install partimage
sudo partimage

Partimage cannot be used from within the partition you wish to backup. You will either have to run it from a different partition or from a LiveCD that contains it. (A serious limitation of Partimage is its inability to backup/restore split image files to/from multiple media (e.g. spanned DVDs/CDs), limiting its usefulness as an inexpensive cloning and distribution solution. Partition image backup/restoration must be to/from a single hard drive, large capacity USB stick, or networked storage space.)

cp

An entire partition's filesystem can easily be copied to another partition using the cp -a command. (However, this cannot be done for the partition of a filesystem that is running. Use the (K)Ubuntu LiveCD to copy partitions when necessary.) Obviously the destination partition should be as large or larger than the source partition, and while not necessary, probably is best if both partitions are of the same filesystem type (e.g. ext4). Use GParted to create or manipulate the destination partition, if necessary. To copy the entire filesystem, for example, from the ext4 partition /dev/sda6 into the ext4 partition at/dev/sda7, mount both partitions:

sudo mkdir /media/partsda6
sudo mkdir /media/partsda7
sudo mount /dev/sda6 -t ext4 /media/partsda6
sudo mount /dev/sda7 -t ext4 /media/partsda7

Then merely copy the contents from one partition to the other:

sudo cp -a /media/partsda6/* /media/partsda7
  • Of course, once the partition's filesystem is copied, a bootmanager (Grub2 or Grub Legacy) will have to be updated/reconfigured to recognize the new partition's OS in order to enable it to boot. Also, the /etc/fstab file of the new partition's filesystem may need to be edited (in regards to the UUIDs of the various partitions), to prevent conflicts. To determine the UUIDs of all current partitions on a hard drive:
sudo blkid

Edit fstab so that the UUIDs are correctly reflected there.

  • To confirm that the file copy has completed, the Linux command du (also see these tips) can be used to calculate the disk usage for both the source and destination folders in order to compare the values (to ensure that they are the same). For example, the values should be the same for both partitions after copying has completed:
sudo du /media/partsda6
sudo du /media/partsda7

dd

dd is a *nix command that enables the copying of files or an entire disk using a single command. Parameters must be precisely specified to avoid risk of accidentally erasing data. See these brief instructions or these instructions for detailed options. You cannot copy a hard drive that contains the operating system you are currently running. Instead, boot into a LiveCD and run the dd command that way. An example command to copy Hard drive X to Hard drive Y is:

dd if=/dev/hdx of=/dev/hdy
  • ddrescue is a variation of the dd command that allows working with potentially corrupted datasets, partitions, or hard drives.

FSArchiver (Filesystem Archiver)

FSArchiver is a utility to backup the filesystem by files (instead of by partition blocks). A filesystem backed up in this way can be moved to a different sized partition or another disk filesystem altogether (e.g. from ext3 to ext4). Backups can be split and stored on (and restored from) spanned media (e.g. multiple DVDs/CDs). It is included in the System Rescue CD. Install:

sudo apt-get install fsarchiver

System Rescue and Cloning Utilities

System Rescue CD

SystemRescueCD is a LiveCD that includes important utilities such as GPartedPartimage, ddrescue, Rsync, andFSArchiver. Several of these utilities cannot be used from within a running partition, so using them from a LiveCD is often necessary. Download and burn the LiveCD from the website.

Clonezilla

Clonezilla allows the backup or duplication of a partition for a single machine or for multiple machines over a network. (It is similar to Norton Ghost.) It includes Partimagepartclone, and other utilities. It is available as a LiveCD which can then be burned. (A serious limitation of Clonezilla is its inability to backup/restore split image files to/from multiple media (e.g. spanned DVDs/CDs), limiting its usefulness as an inexpensive cloning and distribution solution. Partition image backup/restoration must be to/from a single hard drive, large capacity USB stick, or networked storage space.)

Disk Imaging software

  • G4U is a utility to image a disk bit by bit.
  • G4L is a utility to image a disk bit by bit. It includes a GUI interface.

Ubuntu Customization Kit

sudo apt-get install uck

Remastering software

Debian and (K)Ubuntu Linux operating systems can be "remastered" and customized (using one of a number of utilities) for re-distribution. (See this Wikipedia list.) This enables an organization to pre-load desired applications and customizations for distribution among its members, while preserving the intrinsic architecture and function of (K)Ubuntu. The customized (K)Ubuntu OS can then be distributed on a CD or on a USB flashdrive. Users are then free to further customize the OS, or even to revert back to the original default (K)Ubuntu settings. Also see the Ubuntu wiki.

  • oem-config-gtk
sudo apt-get install oem-config-gtk

Run (K)Ubuntu LiveCD from a USB pendrive

The (K)Ubuntu LiveCD can be installed on and run from a USB pendrive. Settings can be "persistently" saved (but the LiveCD kernel modules can not be upgraded). Programs can be installed and run, however, and files saved to the USB drive. (The installed programs will remain installed). A (K)Ubuntu Live CD is needed to do the installation. For additional info, see the Ubuntu Official documentation, the Ubuntu Community documentation or the Pendrivelinux instructions.

The USB "LiveCD" can be used to install (K)Ubuntu on computers (including netbooks) that do not have CD-ROM/DVD drives. See these instructions to boot from a USB flashdrive.

USB pendrives to be used to run (K)Ubuntu should have a minimum of 2 Gb (preferably 4 Gb). If you wish to install a fast, fully functional Linux system on a pendrive that has less memory than that, use PuppyLinux or Lubuntu.

USB Creator

You can make a "LiveCD" on a USB pendrive using USB Creator and either a LiveCD or an .iso version of the LiveCD stored on your hard drive. USB Creator is installed by default in (K)Ubuntu. If not, install:

sudo apt-get install usb-creator-gtk
  • Run:
Menu -> System -> Startup Disk Creator

Create a boot CD to allow booting from the USB drive

Many computers do not allow booting from a USB drive (but they do allow booting from the CD-ROM). You can create a CD-ROM using these Pendrivelinux instructions and set your BIOS to boot from this CD-ROM. When you boot from this CD-ROM, it will use the bootup files on the (K)Ubuntu USB drive you previously created (in the step above).


原文链接:http://ubuntuguide.org/wiki/Ubuntu_Trusty_System_Backup


在进行 Linux 系统升级前,数据备份是确保系统和用户数据安全的重要步骤。以下是一些常见的数据备份方法: ### 1. 完整备份 (Full Backup) 完整备份是指对整个系统或指定目录的所有数据进行全面复制[^2]。这种方法的优点是可以一次性恢复所有数据,而无需依赖其他备份。缺点是占用的存储空间较大,且备份时间较长。 示例命令: ```bash tar -cvpzf backup.tar.gz /path/to/backup ``` ### 2. 差异备份 (Differential Backup) 差异备份类似于增量备份,但它备份的是自上次完整备份以来所有变化的数据。与增量备份相比,差异备份在恢复时更简单,因为它只需要最新的完整备份和最新的差分备份即可恢复数据[^2]。 ### 3. 增量备份 (Incremental Backup) 增量备份备份自上一次备份(无论是完整备份还是增量备份)以来发生变化的数据。这种方法可以节省存储空间并加快备份速度,但在恢复数据时需要依次应用所有的增量备份。 ### 4. 使用版本控制系统 对于源代码或其他文本文件,可以使用 Git 等版本控制系统来跟踪更改,并在需要时回滚到之前的版本。 ### 5. 利用 LVM 快照 如果文件系统支持逻辑卷管理 (LVM),则可以创建快照以捕获文件系统的状态。这允许在不影响生产环境的情况下进行备份操作。 ### 6. 使用专门的备份工具 有许多专为 Linux 设计的备份工具,如 `rsync`, `rdiff-backup`, `Bacula`, `Amanda` 和 `Veeam Agent for Linux` 等。这些工具提供了丰富的功能,包括加密、压缩以及远程备份等。 例如,使用 `rsync` 进行本地备份: ```bash rsync -aAXv /source/directory/ user@remote:/destination/directory/ ``` ### 注意事项 - 在执行任何备份之前,请确保了解哪些数据最为关键。 - 测试你的备份是否能够成功恢复是非常重要的。 - 考虑将备份存放在不同的物理位置或介质上,以防止硬件故障导致数据丢失。 - 对于数据库等动态数据源,在备份时应考虑一致性问题,可能需要停止服务或者使用专门的工具保证数据一致性。 通过上述方法之一或组合使用多种方法,可以在 Linux 系统升级前有效地保护数据安全。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值