个人工具

“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 ...)
 
 
(未显示同一用户的18个中间版本)
第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.
+
== Introduction ==
 
+
Backup is essential. Without it, data is entirely exposed to loss under a number of circumstances such as drive failure or data corruption. Users often only learn this lesson after critical information they require is permanently lost. Attempting to [[UbuntuHelp:DataRecovery|| recover]] from such data loss can be both time consuming and extremely troublesome. So learn from others mistakes, and ensure beforehand that you have a system in place that protects your data and suits your needs.
 
+
Backing up files can be accomplished either from a graphical user interface (GUI) or by issuing commands to the command line interface (CLI). It doesn't matter which method you employ, so long as it works for you and you do it on a regular basis. To make sure it's regular, it's best to ensure your method is scheduled so you don't need to remember to do it.
 
+
== Types of Backup ==
== Using the TAR command ==
+
It is important to note that there are several means of backup, the two primary means being folder synchronization and the creation of archives.
 
+
<u>Folder synchronization</u> is a means to ensure two different folders at two locations hold the same data. The synchronization is usually modified by certain rules, such as directing the program to only write new files. It is most useful for multimedia files that will not benefit from compression. The reason for this is that during encoding of such media near maximal compression is usually achieved with the codec.
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.
+
<u>Creating an archive</u> is mainly used for long-term storage, primarily of configuration files and documents. These will benefit greatly from the compression of gzip or bzip2 because the documents aren't stored in compressed formats. Since the size required on disk is much smaller than storing copies of multimedia files, users often create numerous full backups allowing them to go back and restore files from certain dates.
 
+
A third alternative is called <u>drive imaging</u>. Drive imaging is similar to the creation of archives, except that instead of copying just folders and files, the entire partition that is selected is backed up to an archive byte for byte. Such archives are useful, in the case of a hard drive failure, entire partitions can be restored quickly to a new hard drive and work resumed.
To get a nice tutorial on how to backup using the TAR command, visit this page: [[UbuntuHelp:BackupYourSystem/TAR]]
+
'''WARNING:''' Backups such as drive imaging work at a low level and if improperly used can result in severe data loss, especially with a command line program like dd. Ensure you understand what is being done!
 
+
One final note, some file systems support <u>versioning</u> (snapshots at time intervals), which allows you to see all changes to a file. This is a local backup, but will do nothing in the case of drive failure. See the appropriate section for a discussion.  
 
+
== Backup From a Graphical User Interface ==
== Using Simple Backup Suite (easiest, GUI) ==
+
GUIs offer a graphical interface from which a user can choose from a limited selection of options to customize operation. There are also usually configured defaults and guides that help in selecting the right options. There are a few to choose from, below you'll find several good choices that work well.
 
+
=== Simple Backup Suite ===
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.
+
Simple Backup Suite is a program designed for desktop users. Its purpose is succinctly summarized by its title, to be a simple backup suite. It is easily installed from the repositories and comes with defaults already loaded and configured. From there you can customize what directories it backs up, what it excludes, schedule it to certain times and manage old archives. This suite creates archives, keep that in mind during use.
 
+
For a thorough guide to installation and general use, please see [[UbuntuHelp:BackupYourSystem/SimpleBackupSuite|SimpleBackupSuite]].
To view on how to set up, configure and backup using Simple Backup Suite, please visit this page here: BackupYourSystem/SimpleBackupSuite
+
=== grsync ===
 
+
The program grsync is simply a GUI front end for the CLI utility rsync. It presents a clean yet simple interface for controlling the synchronization between two folders. It also supports multiple sessions (otherwise called profiles) and many of the commonly used basic and advanced options for modifying the synchronization.  
 
+
For more information see the [[UbuntuHelp:rsync#grsync|rsync|page]].
== GRUB restore ==
+
== Backup From the Command Line ==
 
+
CLI's primary advantage over a GUI is that it exposes directly to you many more options. With that however comes the obligation of knowing exactly before hand what you want to do. There are no defaults with commands it's entirely up to the user to set the desired options. To better acquaint yourself beforehand, it is advisable that you read [[UbuntuHelp:UsingTheTerminal|UsingTheTerminal]].
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.
+
=== Creating an Archive ===
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
+
When backing up from the command line '''tar''' is often used. The tar command creates an archive file, which can then be further compressed by gzip or bzip2 to decrease the size it occupies on the disk.
 
+
A full explanation of this command, including how to backup, restore and how to operate over a network among other things can be found at [[UbuntuHelp:BackupYourSystem/TAR|BackupYourSystem/TAR]].
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.
+
 
+
== Other Methods ==
+
 
+
=== 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.
+
 
+
( 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 ).
+
 
+
The command:
+
<pre><nowiki>
+
dd -if /dev/hda1 > partitionimage.dd
+
</nowiki></pre>
+
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:
+
<pre><nowiki>
+
dd -if partitionimage.dd -of /dev/hda1
+
</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.
+
[http://www.trekweb.com/~jasonb/articles/linux_loopback.shtml Mounting disks with Linux's loopback device]
+
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
+
<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: )''
+
 
+
More details on using dd for backup and restore:
+
** [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:
+
** [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 ...''
+
 
+
 
=== rsync ===
 
=== rsync ===
 
+
Rsync updates and 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.
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 a full explanation, there is a separate page about [[UbuntuHelp:rsync|rsync]]. As a companion, the article on [[UbuntuHelp:SSH|SSH]] is worthwhile reading for those wanting to backup over a network.
For safety, transfer between two machines is done via SSH.  Rsync is especially good for backing up home directories.
+
=== dump/restore ===
 
+
A CLI tool used to dump (as name implies) data from a drive to another location. Useful for backups when things are really going wrong on a system, supports incremental backup and is fairly fast. For more information please see its [http://dump.sourceforge.net/ homepage]. A good amount of information on its operation is located within its [[UbuntuHelp:man|man]] page, available the usual way or [http://manpages.ubuntu.com/manpages/karmic/man8/backup_dump.8.html online].
The command for transfering to a remote machine is:
+
== Backup Destination on a Remote Machine ==
<pre><nowiki>
+
=== Simple Backup Suite ===
sudo rsync --delete -azvv -e ssh /home remoteuser@remotehost.remotedomain:./backupdirectory
+
[[UbuntuHelp:BackupYourSystem/SimpleBackupSuite#|SimpleBackupSuite]]
</nowiki></pre>
+
=== Duplicity ===
 
+
[[UbuntuHelp:DuplicityBackupHowto|DuplicityBackupHowto]]
<code><nowiki>-z</nowiki></code> compresses the data
+
<code><nowiki>--delete</nowiki></code> deletes files that don't exist on the system being backed up.  Maybe you want this, maybe not.
+
<code><nowiki>-a</nowiki></code> preserves the date and times of the files (same as <code><nowiki>-t</nowiki></code>), descends recursively into all directories (same as <code><nowiki>-r</nowiki></code>), copies symlinks as symlinks (same as <code><nowiki>-l</nowiki></code>), preserves file permissions (same as <code><nowiki>-p</nowiki></code>), preserves groups (same as <code><nowiki>-g</nowiki></code>), preserves file ownership (same as <code><nowiki>-o</nowiki></code>), and preserves devices as devices (same as <code><nowiki>-D</nowiki></code>).
+
<code><nowiki>-vv</nowiki></code> increases the verbosity of the reporting process
+
 
+
=== UbuntuHomeBackup ===
+
 
+
UbuntuHomeBackup
+
 
+
=== duplicity ===
+
 
+
DuplicityBackupHowto
+
 
+
 
=== BackupPC ===
 
=== BackupPC ===
[[UbuntuHelp:BackupPC]]
+
[[UbuntuHelp:BackupPC|BackupPC]]
 
+
== Drive Imaging ==
== other options ==
+
[[UbuntuHelp:DriveImaging|Drive Imaging]] is a complex topic, and a new article has been created for it. Please see that page for background information and instructions on how to create and restore images of folders or whole partitions.
 
+
== Alternatives ==
 +
=== Versioning File Systems ===
 +
These will be very useful when they mature. For example, ext3cow file system states it, "provides a time-shifting interface that allows a real-time and continuous view of the past.  This allows users to access their file system as it appeared at any point in time." This feature is automatic -- nothing (meaning no backups, manual copies, etc.) need be done to have this benefit when using a copy-on-write file system.
 +
* [http://www.ext3cow.com/Welcome.html ext3cow] (Last release: March 9, 2008)
 +
* [http://wayback.sourceforge.net/ Wayback] (Last release: 2004-06-26)
 +
* [http://n0x.org/copyfs/ CopyFS] (is unmaintained)
 +
* [http://en.wikipedia.org/wiki/Btrfs B-tree FS] (not yet stable - April 2010)
 +
* [http://en.wikipedia.org/wiki/ZFS ZFS] (no native filesystem in ubuntu)
 +
They let you see ''every'' change to a file over its life span, but offer no protection against a hard drive that fails. These projects are therefore complimentary to the backups described above, which offer snapshots or synchronization that can be stored on other hard drives or even other locations on a network.
 +
Versioning tools such as [[UbuntuHelp:Subversion|Subversion]] could also be useful while we wait for versioning file systems to become mature and fully supported.
 +
=== Early Stage Ideas ===
 +
In addition to that already discussed, there are projects still in development that you may wish to keep appraised of or even participate in.
 +
* Ubuntu:ContinuousBackups
 +
* Ubuntu:HomeUserBackup
 +
* Ubuntu:MigrateAndBackup
 +
* Ubuntu:BackupOfPackageUserData
 +
* Ubuntu:UbuntuDownUnder/BOFs/SimpleBackupSolution
 +
* Ubuntu:SessionBackup
 +
== Related Links ==
 
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:
* [http://amanda.zmanda.com/ Amanda]
+
* [[UbuntuWiki:TimeVault|TimeVault]].
* [http://www.partimage.org/ Partimage]
+
* [http://flyback-project.org/ FlyBack].
* [http://www.mondorescue.org/ Mondo Rescue]
+
* [http://backintime.le-web.org/ Back In Time].
* [http://www.rsnapshot.org/ rsnapshot]
+
* [http://amanda.zmanda.com/ Amanda].
* [http://www.csua.berkeley.edu/~emin/source_code/dibs/ DIBS]
+
* [http://www.mondorescue.org/ Mondo Rescue].
* [http://www.bacula.org/ Bacula]
+
* [http://www.rsnapshot.org/ rsnapshot].
[[category:CategoryDocumentation]] [[category:CategoryCleanup]] [[category:CategoryNeedsExpansion]]
+
* [http://www.bacula.org/ Bacula].
 
+
* [http://www.nongnu.org/storebackup/ storeBackup -- it has unique features].
 +
[http://pietrobattiston.it/wiki/doku.php?id=comparison_of_backup_softwares A comparison of graphical backup tools for Linux desktop.]
 
Other wiki discussing various Linux backup techniques:
 
Other wiki discussing various Linux backup techniques:
** [http://www.nslu2-linux.org/wiki/HowTo/BackupYourLinuxBox NSLU2: back up your Linux box]
+
* [http://www.nslu2-linux.org/wiki/HowTo/BackupYourLinuxBox NSLU2: back up your Linux box]
 
+
 
See the full discussion in these threads on the Ubuntu forums:
 
See the full discussion in these threads on the Ubuntu forums:
** http://www.ubuntuforums.org/showthread.php?t=70566
+
* http://ubuntuforums.org/showthread.php?t=868244
** http://www.ubuntuforums.org/showthread.php?t=35087  Howto: Backup and restore your system! (very long thread; but all the good bits have (hopefully) already been summarized on this page.)
+
* http://www.ubuntuforums.org/showthread.php?t=70566
** http://ubuntuforums.org/showthread.php?t=295
+
* http://www.ubuntuforums.org/showthread.php?t=35087  Howto: Backup and restore your system! (very long thread; but all the good bits have (hopefully) already been summarized on this page.)
 
+
* http://ubuntuforums.org/showthread.php?t=295
 
[http://www.debianadmin.com/backup-and-restore-your-ubuntu-system-using-sbackup.html "Backup and Restore Your Ubuntu System using Sbackup"] has nice step-by-step instructions (with screenshots) of using sbackup.
 
[http://www.debianadmin.com/backup-and-restore-your-ubuntu-system-using-sbackup.html "Backup and Restore Your Ubuntu System using Sbackup"] has nice step-by-step instructions (with screenshots) of using sbackup.
 
+
A personal blog listing many open source backup solutions:
Systems like [[UbuntuHelp:Subversion]] and
+
[http://davestechshop.net/ListOfFreeOpenSourceLinuxUbuntuBackupSoftware List of Free Open Source Linux and Ubuntu Backup Software]
[http://wayback.sourceforge.net/ Wayback] and [http://n0x.org/copyfs/ CopyFS]
+
----
are useful when you want to see how things were a week ago -- they let you see *every* change to a file.
+
[[category:CategoryBackupRecovery]] [[category:CategoryCommandLine]]
(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.
+
BackupOfPackageUserData and UbuntuDownUnder/BOFs/SimpleBackupSolution also still needs help.
+
 
+
What exactly does SessionBackup do?
+
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2010年5月19日 (三) 21:40的最新版本


Introduction

Backup is essential. Without it, data is entirely exposed to loss under a number of circumstances such as drive failure or data corruption. Users often only learn this lesson after critical information they require is permanently lost. Attempting to | recover from such data loss can be both time consuming and extremely troublesome. So learn from others mistakes, and ensure beforehand that you have a system in place that protects your data and suits your needs. Backing up files can be accomplished either from a graphical user interface (GUI) or by issuing commands to the command line interface (CLI). It doesn't matter which method you employ, so long as it works for you and you do it on a regular basis. To make sure it's regular, it's best to ensure your method is scheduled so you don't need to remember to do it.

Types of Backup

It is important to note that there are several means of backup, the two primary means being folder synchronization and the creation of archives. Folder synchronization is a means to ensure two different folders at two locations hold the same data. The synchronization is usually modified by certain rules, such as directing the program to only write new files. It is most useful for multimedia files that will not benefit from compression. The reason for this is that during encoding of such media near maximal compression is usually achieved with the codec. Creating an archive is mainly used for long-term storage, primarily of configuration files and documents. These will benefit greatly from the compression of gzip or bzip2 because the documents aren't stored in compressed formats. Since the size required on disk is much smaller than storing copies of multimedia files, users often create numerous full backups allowing them to go back and restore files from certain dates. A third alternative is called drive imaging. Drive imaging is similar to the creation of archives, except that instead of copying just folders and files, the entire partition that is selected is backed up to an archive byte for byte. Such archives are useful, in the case of a hard drive failure, entire partitions can be restored quickly to a new hard drive and work resumed. WARNING: Backups such as drive imaging work at a low level and if improperly used can result in severe data loss, especially with a command line program like dd. Ensure you understand what is being done! One final note, some file systems support versioning (snapshots at time intervals), which allows you to see all changes to a file. This is a local backup, but will do nothing in the case of drive failure. See the appropriate section for a discussion.

Backup From a Graphical User Interface

GUIs offer a graphical interface from which a user can choose from a limited selection of options to customize operation. There are also usually configured defaults and guides that help in selecting the right options. There are a few to choose from, below you'll find several good choices that work well.

Simple Backup Suite

Simple Backup Suite is a program designed for desktop users. Its purpose is succinctly summarized by its title, to be a simple backup suite. It is easily installed from the repositories and comes with defaults already loaded and configured. From there you can customize what directories it backs up, what it excludes, schedule it to certain times and manage old archives. This suite creates archives, keep that in mind during use. For a thorough guide to installation and general use, please see SimpleBackupSuite.

grsync

The program grsync is simply a GUI front end for the CLI utility rsync. It presents a clean yet simple interface for controlling the synchronization between two folders. It also supports multiple sessions (otherwise called profiles) and many of the commonly used basic and advanced options for modifying the synchronization. For more information see the rsync|page.

Backup From the Command Line

CLI's primary advantage over a GUI is that it exposes directly to you many more options. With that however comes the obligation of knowing exactly before hand what you want to do. There are no defaults with commands it's entirely up to the user to set the desired options. To better acquaint yourself beforehand, it is advisable that you read UsingTheTerminal.

Creating an Archive

When backing up from the command line tar is often used. The tar command creates an archive file, which can then be further compressed by gzip or bzip2 to decrease the size it occupies on the disk. A full explanation of this command, including how to backup, restore and how to operate over a network among other things can be found at BackupYourSystem/TAR.

rsync

Rsync updates and 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. For a full explanation, there is a separate page about rsync. As a companion, the article on SSH is worthwhile reading for those wanting to backup over a network.

dump/restore

A CLI tool used to dump (as name implies) data from a drive to another location. Useful for backups when things are really going wrong on a system, supports incremental backup and is fairly fast. For more information please see its homepage. A good amount of information on its operation is located within its man page, available the usual way or online.

Backup Destination on a Remote Machine

Simple Backup Suite

SimpleBackupSuite

Duplicity

DuplicityBackupHowto

BackupPC

BackupPC

Drive Imaging

Drive Imaging is a complex topic, and a new article has been created for it. Please see that page for background information and instructions on how to create and restore images of folders or whole partitions.

Alternatives

Versioning File Systems

These will be very useful when they mature. For example, ext3cow file system states it, "provides a time-shifting interface that allows a real-time and continuous view of the past. This allows users to access their file system as it appeared at any point in time." This feature is automatic -- nothing (meaning no backups, manual copies, etc.) need be done to have this benefit when using a copy-on-write file system.

  • ext3cow (Last release: March 9, 2008)
  • Wayback (Last release: 2004-06-26)
  • CopyFS (is unmaintained)
  • B-tree FS (not yet stable - April 2010)
  • ZFS (no native filesystem in ubuntu)

They let you see every change to a file over its life span, but offer no protection against a hard drive that fails. These projects are therefore complimentary to the backups described above, which offer snapshots or synchronization that can be stored on other hard drives or even other locations on a network. Versioning tools such as Subversion could also be useful while we wait for versioning file systems to become mature and fully supported.

Early Stage Ideas

In addition to that already discussed, there are projects still in development that you may wish to keep appraised of or even participate in.

  • Ubuntu:ContinuousBackups
  • Ubuntu:HomeUserBackup
  • Ubuntu:MigrateAndBackup
  • Ubuntu:BackupOfPackageUserData
  • Ubuntu:UbuntuDownUnder/BOFs/SimpleBackupSolution
  • Ubuntu:SessionBackup

Related Links

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

A comparison of graphical backup tools for Linux desktop. 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. A personal blog listing many open source backup solutions: List of Free Open Source Linux and Ubuntu Backup Software