个人工具

“UbuntuHelp:BackupYourSystem”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(新页面: {{From|https://help.ubuntu.com/community/BackupYourSystem}} {{Languages|UbuntuHelp:BackupYourSystem}} Backing up your system is an important thing for everyone to do. You never know when ...)
 
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/BackupYourSystem}}
 
{{From|https://help.ubuntu.com/community/BackupYourSystem}}
 
{{Languages|UbuntuHelp:BackupYourSystem}}
 
{{Languages|UbuntuHelp:BackupYourSystem}}
Backing up your system is an important thing for everyone to do. You never know when your hard drive will die, or some other disaster strikes. You don't want to lose all of your bookmarks, pictures from vacations, documents, school papers, music, and more just because you did not make a recent backup. It can be as simple as backing up the most important things on your computer to a CD or DVD, or using one of the methods here for backing up your entire /home directory, or maybe your whole computer. There are several methods listed here for you to choose from.
 
  
  
 +
Backing up your system important, since you never know when your hard drive will die or some other disaster will strike. Several backup methods are listed below.
  
== Using the TAR command ==
+
== Archival backup ==
  
This requires using the command line (aka the terminal) It makes a backup of your root or whatever directory you want to backup into a nice TAR file. You can backup to remote directories, different hard drives, to a CD or DVD (if the finished tar file is over 2gb, you will have to use the "split" command and use multiple cd's or dvd's.
+
=== From the command line ===
  
To get a nice tutorial on how to backup using the TAR command, visit this page: [[UbuntuHelp:BackupYourSystem/TAR]]
+
==== Using the TAR command ====
  
 +
Suitable for backing up your home directory. Open a terminal and enter the command:
  
== Using Simple Backup Suite (easiest, GUI) ==
+
<pre><nowiki>
 
+
tar cvfz output input
Simple Backup Suite is a program that was created during the Google Summer of Code 2005. It is program with a GNOME interface (if you use KDE or some other work manager, you might need to install some stuff in order to run Simple Backup Suite). You can specify how often it backs up (or not automatically at all), the destination (including remote locations), what file types / directories to exclude and what directories you want it to back up. Simple Backup Suite also makes incremental backups, so once you do a full backup, all backups after that are simply what has changed between the last full backup and your increment. You can also configure the rules that old backups get deleted.
+
</nowiki></pre>
 
+
To view on how to set up, configure and backup using Simple Backup Suite, please visit this page here: BackupYourSystem/SimpleBackupSuite
+
 
+
 
+
== GRUB restore ==
+
 
+
Now, if you want to move your system to a new harddisk or if you did something nasty to your GRUB (like, say, install Windows), You'll also need to reinstall GRUB.
+
There are several very good howto's on how to do that here on this forum, so i'm not going to reinvent the wheel. Instead, take a look [http://www.ubuntuforums.org/showthread.php?t=24113&highlight=grub+restore here] (forum) or here: RecoveringUbuntuAfterInstallingWindows
+
  
On the forum thread, there are a couple of methods proposed. I personally recommend the second one, posted by remmelt, since that has always worked for me.
+
The compressed image created can be broken into smaller chunks for copying to removeable media using the split command.
  
== Other Methods ==
+
More information can be found here: [[UbuntuHelp:BackupYourSystem/TAR]]
  
=== dd ===
+
==== Creating disc images using dd ====
  
If you want to back up an entire partition, or an entire hard drive (including the MBR), no matter what operating system is installed on it, "dd" is the way to go.
+
Suitable for backing up entire disks. Open a terminal (in the examples you will need to replace hda with the partition you wish to backup).
 
+
( http://packages.ubuntu.com/edgy/admin/partimage may be an easier way to back up entire partitions, but it apparently (?) can't back up the MBR, and there are a few obscure operating systems it doesn't fully support ).
+
  
 +
Create a hard disk image:
 +
<pre><nowiki>
 +
dd if=/dev/hda1 of=/home/hda1.bin
 +
</nowiki></pre>
 +
Create a compressed disk image
 +
<pre><nowiki>
 +
dd if=/dev/hda1 | gzip > /home/hda1.bin.gz
 +
</nowiki></pre>
 +
Back up the MBR
 +
<pre><nowiki>
 +
dd if=/dev/hda of=/home/hda.boot.mbr bs=512 count=1
 +
</nowiki></pre>
 +
Restore MBR (from a Live CD)
 +
<pre><nowiki>
 +
dd if=/mnt/hda1/home/hda.boot.mbr of=/dev/hda bs=512 count=1
 +
</nowiki></pre>
 +
Backup a drive to another drive
 +
<pre><nowiki>
 +
dd if=/dev/hda of=/dev/hdb conv=noerror,sync bs=4k
 +
</nowiki></pre>
 
The command:
 
The command:
 
<pre><nowiki>
 
<pre><nowiki>
第42行: 第53行:
 
dd -if partitionimage.dd -of /dev/hda1
 
dd -if partitionimage.dd -of /dev/hda1
 
</nowiki></pre>
 
</nowiki></pre>
You can also pipe through gzip or bzip2 to compress the images.
 
  
 
You can use the "loopback device" to mount this partition image, making it easy to read the old version of files and still keep your current version untouched.
 
You can use the "loopback device" to mount this partition image, making it easy to read the old version of files and still keep your current version untouched.
第48行: 第58行:
 
by Jason Boxman
 
by Jason Boxman
  
For example, on my system, to back up the entire "hda" drive of some random computer running some random operating system, I reboot with Ubuntu LiveCD, then do
+
== From the Desktop ==
<pre><nowiki>
+
sudo dd if=/dev/hda | gzip -c | ssh -v -c blowfish [email protected] "dd of=backup_latitude_2007-02-28.gz"
+
</nowiki></pre>
+
then type in my password on the remote system (to the "davidcary" account on the Ubuntu file server at 192.168.128.80 -- your system will likely be different).
+
The transfer rate seemed to be limited by my (1 GHz) laptop CPU, since the transfer rate never went above 3 MiB/s on my 100 Mbps Ethernet; the total transfer time was about an hour and a half, creating a file almost 9 GB.
+
-- DavidCary
+
  
''(fixme: summarize the information in the following links: )''
+
=== Using Simple Backup Suite ===
  
More details on using dd for backup and restore:
+
Simple Backup Suite is a program that was created during the Google Summer of Code 2005. Using a familiar GNOME interface, you can specify how often it backs up, the destination, what to exclude and what to back up.
** [http://www.inference.phy.cam.ac.uk/saw27/notes/backup-hard-disk-partitions.html "Notes on backing up entire hard disks or partitions"]
+
** [http://www.cpqlinux.com/ddbackup.html "Using DD to backup your drive"]
+
** [http://www.sysdesign.ca/guides/partitions.html "Copying/resizing partitions for a dual boot system"]
+
  
More details on backing up the MBR:
+
Simple Backup Suite also makes incremental backups, after creating the initial backup, only the files that have changed are backed up.
** [https://blueprints.launchpad.net/ubuntu/+spec/installation-backup-mbr "Ubuntu ... Option to automatically back up the MBR during installation]
+
 
** [http://ubuntu.wordpress.com/2005/10/20/backing-up-the-mbr/ Backing Up the MBR] ''note: read the comments, which have an important correction ...''
+
For more information see: BackupYourSystem/SimpleBackupSuite
 +
 
 +
=== UbuntuHomeBackup ===
 +
 
 +
Ubuntu/UbuntuHomeBackup
 +
 
 +
=== duplicity ===
 +
 
 +
DuplicityBackupHowto
 +
 
 +
=== BackupPC ===
 +
[[UbuntuHelp:BackupPC]]
 +
 
 +
== Incremental Backup ==
  
 
=== rsync ===
 
=== rsync ===
第82行: 第96行:
 
<code><nowiki>-vv</nowiki></code> increases the verbosity of the reporting process
 
<code><nowiki>-vv</nowiki></code> increases the verbosity of the reporting process
  
=== UbuntuHomeBackup ===
+
== See also ==
 
+
UbuntuHomeBackup
+
 
+
=== duplicity ===
+
 
+
DuplicityBackupHowto
+
 
+
=== BackupPC ===
+
[[UbuntuHelp:BackupPC]]
+
 
+
== other options ==
+
  
 
You might also want to check out these backup programs which will help you to make automated backups of your system:
 
You might also want to check out these backup programs which will help you to make automated backups of your system:
第100行: 第103行:
 
* [http://www.mondorescue.org/ Mondo Rescue]
 
* [http://www.mondorescue.org/ Mondo Rescue]
 
* [http://www.rsnapshot.org/ rsnapshot]
 
* [http://www.rsnapshot.org/ rsnapshot]
* [http://www.csua.berkeley.edu/~emin/source_code/dibs/ DIBS]
 
 
* [http://www.bacula.org/ Bacula]
 
* [http://www.bacula.org/ Bacula]
[[category:CategoryDocumentation]] [[category:CategoryCleanup]] [[category:CategoryNeedsExpansion]]
+
 
  
 
Other wiki discussing various Linux backup techniques:
 
Other wiki discussing various Linux backup techniques:
第119行: 第121行:
 
(But they don't help when the hard drive fails, so they are complementary to these other forms of backup that only store occasional snapshots, but also survive hardware failures).
 
(But they don't help when the hard drive fails, so they are complementary to these other forms of backup that only store occasional snapshots, but also survive hardware failures).
  
ContinuousBackups and HomeUserBackup and MigrateAndBackup have some interesting ideas about making backups completely automated.
+
Ubuntu:ContinuousBackups and Ubuntu:HomeUserBackup and Ubuntu:MigrateAndBackup have some interesting ideas about making backups completely automated.
BackupOfPackageUserData and UbuntuDownUnder/BOFs/SimpleBackupSolution also still needs help.
+
Ubuntu:BackupOfPackageUserData and Ubuntu:UbuntuDownUnder/BOFs/SimpleBackupSolution also still needs help.
 +
 
 +
What exactly does Ubuntu:SessionBackup do?
  
What exactly does SessionBackup do?
+
----
 +
[[category:CategoryDocumentation]]  [[category:CategoryNeedsExpansion]]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2007年11月22日 (四) 12:04的版本



Backing up your system important, since you never know when your hard drive will die or some other disaster will strike. Several backup methods are listed below.

Archival backup

From the command line

Using the TAR command

Suitable for backing up your home directory. Open a terminal and enter the command:

tar cvfz output input

The compressed image created can be broken into smaller chunks for copying to removeable media using the split command.

More information can be found here: UbuntuHelp:BackupYourSystem/TAR

Creating disc images using dd

Suitable for backing up entire disks. Open a terminal (in the examples you will need to replace hda with the partition you wish to backup).

Create a hard disk image:

dd if=/dev/hda1 of=/home/hda1.bin

Create a compressed disk image

dd if=/dev/hda1 | gzip > /home/hda1.bin.gz

Back up the MBR

dd if=/dev/hda of=/home/hda.boot.mbr bs=512 count=1

Restore MBR (from a Live CD)

dd if=/mnt/hda1/home/hda.boot.mbr of=/dev/hda bs=512 count=1

Backup a drive to another drive

dd if=/dev/hda of=/dev/hdb conv=noerror,sync bs=4k

The command:

dd -if /dev/hda1 > partitionimage.dd

will backup "/dev/hda1", the first partition on hda1. A whole drive (including the MBR) could be backed up using just /dev/hda as the input "file". Restoring is done by:

dd -if partitionimage.dd -of /dev/hda1

You can use the "loopback device" to mount this partition image, making it easy to read the old version of files and still keep your current version untouched. Mounting disks with Linux's loopback device by Jason Boxman

From the Desktop

Using Simple Backup Suite

Simple Backup Suite is a program that was created during the Google Summer of Code 2005. Using a familiar GNOME interface, you can specify how often it backs up, the destination, what to exclude and what to back up.

Simple Backup Suite also makes incremental backups, after creating the initial backup, only the files that have changed are backed up.

For more information see: BackupYourSystem/SimpleBackupSuite

UbuntuHomeBackup

Ubuntu/UbuntuHomeBackup

duplicity

DuplicityBackupHowto

BackupPC

UbuntuHelp:BackupPC

Incremental Backup

rsync

Rsync updates the copies the files that have changed and even then only transfers the parts of those files that have changed. That is useful for saving bandwidth when backing up over the network. For safety, transfer between two machines is done via SSH. Rsync is especially good for backing up home directories.

The command for transfering to a remote machine is:

sudo rsync --delete -azvv -e ssh /home [email protected]:./backupdirectory

-z compresses the data --delete deletes files that don't exist on the system being backed up. Maybe you want this, maybe not. -a preserves the date and times of the files (same as -t), descends recursively into all directories (same as -r), copies symlinks as symlinks (same as -l), preserves file permissions (same as -p), preserves groups (same as -g), preserves file ownership (same as -o), and preserves devices as devices (same as -D). -vv increases the verbosity of the reporting process

See also

You might also want to check out these backup programs which will help you to make automated backups of your system:


Other wiki discussing various Linux backup techniques:

See the full discussion in these threads on the Ubuntu forums:

"Backup and Restore Your Ubuntu System using Sbackup" has nice step-by-step instructions (with screenshots) of using sbackup.

Systems like UbuntuHelp:Subversion and Wayback and CopyFS are useful when you want to see how things were a week ago -- they let you see *every* change to a file. (But they don't help when the hard drive fails, so they are complementary to these other forms of backup that only store occasional snapshots, but also survive hardware failures).

Ubuntu:ContinuousBackups and Ubuntu:HomeUserBackup and Ubuntu:MigrateAndBackup have some interesting ideas about making backups completely automated. Ubuntu:BackupOfPackageUserData and Ubuntu:UbuntuDownUnder/BOFs/SimpleBackupSolution also still needs help.

What exactly does Ubuntu:SessionBackup do?