Diff for "BackupYourSystem"


Differences between revisions 1 and 123 (spanning 122 versions)
Revision 1 as of 2005-07-17 23:09:38
Size: 6695
Editor: 81-179-215-74
Comment: created
Revision 123 as of 2015-02-23 01:56:55
Size: 7615
Editor: p5B3C8EA7
Comment: clonezilla
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Backup Your System = ||<tablestyle="float:right; font-size:0.9em; width:40%; background:#F1F1ED; margin: 0 0 1em 1em;" style="padding:0.5em;"><<TableOfContents>>||
Line 3: Line 3:
This guide to backup your system using tar to create compressed archives was taken from the post on the Ubuntu Forum written by Heliode. See the thread for discussion: http://www.ubuntuforums.org/showthread.php?t=35087 = Introduction =
Backup and recovery is essential. Failure to have verified backup and recovery procedures puts your data at risk of loss. Users often only learn this lesson after critical information they require is permanently lost. Attempting to [[https://help.ubuntu.com/community/DataRecovery | recover]] from such data loss can be both time consuming and extremely difficult. So learn from others mistakes, and ensure beforehand that you have a system in place that protects your data and suits your needs.
Line 5: Line 6:
[[TableOfContents]] Before deciding on a backup and recovery strategy you have to ask the following questions:
  * '''Why'''? - Why are you protecting yourself against disaster? Does it matter if you lose data? What losses will you suffer ($$$)?
  * '''What'''? - What are you going to backup? Your entire hard drive or just some of the data?
  * '''When'''? - When is the best time to backup your system? How often will you perform a backup? When will you use full backups and incremental backups.
  * '''Where'''? - Where will the backups be stored? On-site? Off-Site? Cloud?
  * '''Medium'''? - Attached storage (usb stick, usb hard drive, tape drive), backup server?
Line 7: Line 13:
Hi, and welcome to the Heliode guide to successful backing-up and restoring of a Linux system!

Most of you have probably used Windows before you started using Ubuntu. During that time you might have needed to backup and restore your system. For Windows you would need proprietary software for which you would have to reboot your machine and boot into a special environment in which you could perform the backing-up/restoring (programs like Norton Ghost).
During that time you might have wondered why it wasn't possible to just add the whole c:\ to a big zip-file. This is impossible because in Windows, there are lots of files you can't copy or overwrite while they are being used, and therefore you needed specialized software to handle this.

Well, I'm here to tell you that those things, just like rebooting, are Windows Crazy Things (tm). There's no need to use programs like Ghost to create backups of your Ubuntu system (or any Linux system, for that matter). In fact; using Ghost might be a very bad idea if you are using anything but ext2. Ext3, the default Ubuntu partition, is seen by Ghost as a damaged ext2 partition and does a very good job at screwing up your data.

== Backing-up ==

"What should I use to backup my system then?" might you ask. Easy; the same thing you use to backup/compress everything else; TAR. Unlike Windows, Linux doesn't restrict root access to anything, so you can just throw every single file on a partition in a TAR file!

To do this, become root with
= Backup =
== Types of Backup ==
There are many methods to provide backup and recovery; choosing the best process for you or your business will have to take several factors in to account.
  * Recovery time objective ('''RTO'''): How fast should data be recovered? Can you continue to operate if data recovery is not recovered for a day, a week, etc?
  * Recovery point objective ('''RPO'''): How much data can be lost. Can you lose two hours, two days or two weeks of data?
Line 21: Line 20:
sudo su example: if you can withstand losing one week of data then a weekly backup would be sufficient, but if you can only withstand losing one day then you would need to employ a nightly backup (or a variation)
Line 24: Line 23:
and go to the root of your filesystem (we use this in our example, but you can go anywhere you want your backup to end up, including remote or removable drives.) This document will cover three basic types of backup; Full, Incremental and Differential.

'''Full'''
A full backup backs up all the files in the back up target.

'''Incremental'''
An incremental backup backs up all the files that have changed since the last backup.

'''Differential'''
A differential backup is the same as an incremental except if Windows files systems are involved. In that case it is a backup that does not clear the archive bit.

== Backup Methods ==
Depending on your budget and specific RTO and RPO you can choose from manual, local automated or remote automated.

  * '''manual''' - manual backup would be initiated on a schedule by the user and is the most common method for home users to backup their files. This method is also the least reliable.
  * '''local automated''' - automated backups that target a hard drive or tape drive attached to the physical box being backed up fall in to this category. Advanced home users and small businesses will often use this method.
  * '''remote automated''' - automated backups that target a hard drive, tape drive or virtual tape library (VTL) over the network fall in to this backup. This type of backup is often used by businesses that have money they can dedicate to the process of backup. As the organization becomes more mature they may even stage the backup on multiple mediums and increase the distance between backup and production systems.

== mtime, atime and ctime ==
Ubuntu records three different times for each file:
  * mtime - modification time; this value is changed when the contents of the file is changed
  * atime - access time; the value of this is changed when the file is accessed. The atime can change when a backup utility or script read the file as well as when a use reads the file
  * ctime - change time; the value is updated whenever the attributes of the file change. This can be ownership or permissions
Line 27: Line 48:
cd / note: file system backups change atime while raw device backups will not. If you are implementing incremental or differential backups this is important
Line 30: Line 51:
Now, below is the full command I would use to make a backup of my system:
= Recovery =
Line 33: Line 53:
tar cvpzf backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys note: many people consider only the backup part of this process and do nothing to verify that the backup can be restored. It is very important to test that your back up process is working and that data can be recovered.
Line 36: Line 56:
Now, lets explain this a little bit:
 * The 'tar' part is, obviously, the program we're going to use.
 * 'cvpfz' are the options we give to tar, like 'create archive' (obviously), 'preserve permissions'(to keep the same permissions on everything the same), and 'gzip' to keep the size down.
 * Next, the name the archive is going to get. backup.tgz in our example.
 * Next comes the root of the directory we want to backup. Since we want to backup everything; /
 * Now come the directories we want to exclude. We don't want to backup everything since some dirs aren't very useful to include. Also make sure you don't include the file itself, or else you'll get weird results. You might also not want to include the /mnt folder if you have other partitions mounted there or you'll end up backing those up too. Also make sure you don't have anything mounted in /media (i.e. don't have any cd's or removable media mounted). Either that or exclude /media.
It is crucial that your backups be tested by restoring from them. Here are some tests you should do to ensure you can recover from a disaster:
  * Restore many single files
  * Restore an older version of a file
  * Restore an entire folder
  * Restore an entire drive and compare the checksum
Line 43: Line 62:
EDIT: kvidell suggests on the forum thread that we also exclude the /dev directory. I have other evidence that says it is very unwise to do so though. If you do not test you may find out that nothing was being backed up when you need to restore the files in reality.
Line 45: Line 64:
Well, if the command agrees with you, hit enter (or return, whatever) and sit back&relax. This might take a while. = Backup Utilities =
== wiki documented utilities ==
||<tablestyle="width:100%;background:#F4F3F1" rowstyle="font-weight: bold; text-align: center; background:#592441;color:#FFFFFF;" |2>Utility||<|2>Interface||<|2> Raw / File ||<-4> Supports ||
||<rowstyle="font-weight: bold; text-align: center;background:#592441; color:#FFFFFF;"> Remote || Incremental || Differential || Automation ||
||[[https://wiki.gnome.org/action/show/Apps/DejaDup?action=show&redirect=DejaDup|Déjà Dup]]|| Graphical (Duplicity frontend) || FILE || YES || YES || YES || YES ||
||[[https://help.ubuntu.com/community/rsync#Grsync|grsync]]|| Graphical || FILE || YES || YES || YES || via Cron ||
||[[http://wiki.ubuntuusers.de/pybackpack|pybackpack]]|| Graphical || FILE || YES || YES || ? || NO ||
||[[BackupYourSystem/TAR|TAR]]|| Command line || FILE || YES || YES || YES || via Cron ||
||[[rsync]]|| Command line || FILE || YES || YES || YES || via Cron ||
||[[http://manpages.ubuntu.com/manpages/karmic/man8/backup_dump.8.html|dump]]||Command line||RAW|| YES || YES || YES || via Cron ||
||[[DuplicityBackupHowto|Duplicity]]|| Command line || FILE || YES || YES || YES || via Cron ||
||[[BackupPC]]|| Command line || FILE || YES || YES || YES || via Cron ||
||Bacula [[https://help.ubuntu.com/10.04/serverguide/C/bacula.html|1]] [[Bacula|2]]|| Both || FILE || YES || YES || YES || YES ||
||[[MondoMindi|Mondo Rescue]]|| Command line || FILE || YES || YES || YES || YES ||
||[[BackupYourSystem/SimpleBackupSuite|SimpleBackupSuite]]|| Graphical || FILE || YES || YES || ? || YES ||
||[[http://manpages.ubuntu.com/manpages/natty/en/man8/backup-manager.8.html|backup-manager]]|| Command line || FILE || YES || YES || YES || via Cron ||
Line 47: Line 81:
Afterwards you'll have a file called backup.tgz in the root of your filessytem, which is probably pretty large. Now you can burn it to DVD or move it to another machine, whatever you like! = Alternatives =
== Related Links ==
You might also want to check out these backup programs which will help you to make automated backups of your system:
Line 49: Line 85:
EDIT2:
At the end of the process you might get a message along the lines of 'tar: Error exit delayed from previous errors' or something, but in most cases you can just ignore that.
 * Clonezilla with Text GUI interface, backs up whole disks with boot sectors etc.
 * [[https://apps.ubuntu.com/cat/applications/deja-dup/|Déjà Dup]] (Ubuntu's default desktop backup manager)
 * [[https://wiki.ubuntu.com/TimeVault|TimeVault]].
 * [[http://flyback-project.org/|FlyBack]].
 * [[http://backintime.le-web.org/|Back In Time]].
 * [[http://amanda.zmanda.com/|Amanda]].
 * [[http://www.rsnapshot.org/|rsnapshot]].
 * [[http://www.nongnu.org/storebackup/|storeBackup -- it has unique features]].
Line 52: Line 94:
Alternatively, you can use Bzip2 to compress your backup. This means higher compression but lower speed. If compression is important to you, just substitute
the 'z' in the command with 'j', and give the backup the right extension.
That would make the command look like this:
= Discussions and Suggestions =
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
Line 56: Line 103:
{{{
tar cvpjf backup.tar.bz2 / --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys
}}}

== Restoring ==

attachment:IconsPage/IconWarning3.png Warning: Please, for goodness sake, be careful here. If you don't understand what you are doing here you might end up overwriting stuff that is important to you, so please take care!

Well, we'll just continue with our example from the previous chapter; the file backup.tgz in the root of the partition.

Once again, make sure you are root and that you and the backup file are in the root of the filesystem.

One of the beautiful things of Linux is that This'll work even on a running system; no need to screw around with boot-cd's or anything. Of course, if you've rendered your system unbootable you might have no choice but to use a live-cd, but the results are the same. You can even remove every single file of a Linux system while it is running with one command. I'm not giving you that command though!

Well, back on-topic.
This is the command that I would use:

{{{
tar xvpfz backup.tgz -C /
}}}

Or if you used bz2;

{{{
tar xvpfj backup.tar.bz2 -C /
}}}


attachment:IconsPage/IconWarning3.png WARNING: this will overwrite every single file on your partition with the one in the archive!

Just hit enter/return/your brother/whatever and watch the fireworks. Again, this might take a while. When it is done, you have a fully restored Ubuntu system! Just make sure that, before you do anything else, you re-create the directories you excluded:

{{{
mkdir proc mkdir lost+found mkdir mnt mkdir sys etc...
}}}

And when you reboot, everything should be the way it was when you made the backup!

=== 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.

Well that's it! I hope it was helpful!

== Other Methods ==

You might also want to check out these backup programs which will help you to make automated backups of your system:
 * [http://www.partimage.org/ Partimage]
 * [http://www.mondorescue.org/ Mondo Rescue]
----
CategoryBackupRecovery CategoryCommandLine

Introduction

Backup and recovery is essential. Failure to have verified backup and recovery procedures puts your data at risk of loss. 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 difficult. So learn from others mistakes, and ensure beforehand that you have a system in place that protects your data and suits your needs.

Before deciding on a backup and recovery strategy you have to ask the following questions:

  • Why? - Why are you protecting yourself against disaster? Does it matter if you lose data? What losses will you suffer ($$$)?

  • What? - What are you going to backup? Your entire hard drive or just some of the data?

  • When? - When is the best time to backup your system? How often will you perform a backup? When will you use full backups and incremental backups.

  • Where? - Where will the backups be stored? On-site? Off-Site? Cloud?

  • Medium? - Attached storage (usb stick, usb hard drive, tape drive), backup server?

Backup

Types of Backup

There are many methods to provide backup and recovery; choosing the best process for you or your business will have to take several factors in to account.

  • Recovery time objective (RTO): How fast should data be recovered? Can you continue to operate if data recovery is not recovered for a day, a week, etc?

  • Recovery point objective (RPO): How much data can be lost. Can you lose two hours, two days or two weeks of data?

example: if you can withstand losing one week of data then a weekly backup would be sufficient, but if you can only withstand losing one day then you would need to employ a nightly backup (or a variation)

This document will cover three basic types of backup; Full, Incremental and Differential.

Full A full backup backs up all the files in the back up target.

Incremental An incremental backup backs up all the files that have changed since the last backup.

Differential A differential backup is the same as an incremental except if Windows files systems are involved. In that case it is a backup that does not clear the archive bit.

Backup Methods

Depending on your budget and specific RTO and RPO you can choose from manual, local automated or remote automated.

  • manual - manual backup would be initiated on a schedule by the user and is the most common method for home users to backup their files. This method is also the least reliable.

  • local automated - automated backups that target a hard drive or tape drive attached to the physical box being backed up fall in to this category. Advanced home users and small businesses will often use this method.

  • remote automated - automated backups that target a hard drive, tape drive or virtual tape library (VTL) over the network fall in to this backup. This type of backup is often used by businesses that have money they can dedicate to the process of backup. As the organization becomes more mature they may even stage the backup on multiple mediums and increase the distance between backup and production systems.

mtime, atime and ctime

Ubuntu records three different times for each file:

  • mtime - modification time; this value is changed when the contents of the file is changed
  • atime - access time; the value of this is changed when the file is accessed. The atime can change when a backup utility or script read the file as well as when a use reads the file
  • ctime - change time; the value is updated whenever the attributes of the file change. This can be ownership or permissions

note: file system backups change atime while raw device backups will not. If you are implementing incremental or differential backups this is important

Recovery

note: many people consider only the backup part of this process and do nothing to verify that the backup can be restored. It is very important to test that your back up process is working and that data can be recovered.

It is crucial that your backups be tested by restoring from them. Here are some tests you should do to ensure you can recover from a disaster:

  • Restore many single files
  • Restore an older version of a file
  • Restore an entire folder
  • Restore an entire drive and compare the checksum

If you do not test you may find out that nothing was being backed up when you need to restore the files in reality.

Backup Utilities

wiki documented utilities

Utility

Interface

Raw / File

Supports

Remote

Incremental

Differential

Automation

Déjà Dup

Graphical (Duplicity frontend)

FILE

YES

YES

YES

YES

grsync

Graphical

FILE

YES

YES

YES

via Cron

pybackpack

Graphical

FILE

YES

YES

?

NO

TAR

Command line

FILE

YES

YES

YES

via Cron

rsync

Command line

FILE

YES

YES

YES

via Cron

dump

Command line

RAW

YES

YES

YES

via Cron

Duplicity

Command line

FILE

YES

YES

YES

via Cron

BackupPC

Command line

FILE

YES

YES

YES

via Cron

Bacula 1 2

Both

FILE

YES

YES

YES

YES

Mondo Rescue

Command line

FILE

YES

YES

YES

YES

SimpleBackupSuite

Graphical

FILE

YES

YES

?

YES

backup-manager

Command line

FILE

YES

YES

YES

via Cron

Alternatives

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

Discussions and Suggestions

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


CategoryBackupRecovery CategoryCommandLine

BackupYourSystem (last edited 2024-01-18 13:08:08 by kobicat)