Diff for "BackupYourSystem"


Differences between revisions 67 and 68
Revision 67 as of 2009-07-25 20:49:33
Size: 14228
Editor: 76-10-183-102
Comment:
Revision 68 as of 2009-07-27 21:53:14
Size: 14545
Editor: 69-165-152-223
Comment: Cleaned up and added some more information. A guide still needs to be made for grsync, and the CLI section needs further cleaning.
Deletions are marked like this. Additions are marked like this.
Line 26: Line 26:
Not yet written, feel free to add section. 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.

See the following sub page for a guide. Yet to be created.
Line 171: Line 173:
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. They let you see ''every'' change to a file over it's 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.
Line 175: Line 177:
= See also =
= Related Links =
Line 203: Line 204:
= Other Early Stage Ideas =
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?

Are there more user-friendly solutions than the destroy disk command (dd)? Is there another way to backup the MBR?
= 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

Tag/tag.png

Needs Expansion
This article is incomplete, and needs to be expanded. More info...

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.

It is also important to note that there are two primary means of backup. 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 multimedia near maximal compression is usually achieved.

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 due to their nature, they 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.

One final note, some file systems support versioning, 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.

Simple Backup Suite

Simple Backup Suite is a program designed for desktop users. It's purpose is succinctly summarized by it's 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 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.

See the following sub page for a guide. Yet to be created.

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.

Depending on what you are backing up superuser access might be needed. For instance, if you want to backup your configuration files in /etc. For an understanding of why this is needed, see FilePermissions.

To begin open Applications -> Accessories -> Terminal and type the following command and return.

sudo -s -H 

This will give you root access for the duration of your terminal session. _Take_ _care_ with the commands typed from here on out, you have access to everything on your disk.

For this example, we will change directory to the root, this is where the archive file will be created. You may decide to use another directory, including external drives or other removable media. That is entirely up to you.

cd /

Below is the command to make the back up, to understand what is happening read on.

tar cvpzf my_backup.tar.gz --exclude=/proc --exclude=/lost+found –exclude=/my_backup.tar.gz --exclude=/mnt --exclude=/sys / 

What is all that doing?

  • tar is the program we are using to do a backup

  • cvpfz are the options we give to tar

    • c - create a new backup archive

    • v - verbose mode, tar will print what it does to the screen

    • z - compress the backup file with 'gzip' to make it smaller

    • f <filename> - specifies where to store the backup, my_backup.tar.gz is the file used in this example

  • --exclude= - defines what directories should be ignored during the operation.

    • Make sure you don't include the file itself, this will produce undesirable results.
    • Don't include the /mnt folder if you have other partitions mounted there.

    • If you have Partitions in /mnt that require backup, you will need to exclude the folders you do not want.

    • Make sure you don't have anything mounted in /media.

      • Remove CDs/DVDs and removable media that you don't need backed up. You can selectively exclude directories in /media if you want removable devices backed up.

  • / - After all the options, we designate what we do want backed up. In this example, we've decided to back up everything under root.

When your satisfied with the options, push Enter. When the process is complete you will have a file named my_backup.tar.gz in the root directory of your file system. Most people will make multiple archives over time, so it is wise to put the date of creation in the name of the file. Say for example, my_backup.06.20.2009.tar.gz
Alternatively, you can use Bzip2 to compress your backup. Bzip2 was developed after gzip and will result in less disk space used by the archive at the cost of speed of the operation. To use bzip2, simply substitute the z in the command with j, and change the extensions accordingly.

That would make the command look like this:

tar cvpjf my_backup.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/my_backup.tar.bz2 --exclude=/mnt --exclude=/sys / 

More information can be found here: 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

If you have a complete new harddrive and want to restore the backup (or copy your old system to the new drive). First, the new drive has to be bigger or exactly the same size as the old one.

First go superuser and switch to runlevel 1 so that you can fumble around with the harddisk without other services interfering:

sudo su
init 1

restore either the whole disk to the new drive or one partition (depending on how you made the backup):

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

If you restored the whole drive (/dev/hda), the system will not automatically create the devices (/dev/hda1, /dev/hda2) if you just restored the whole drive. If you know how to make the devices show up without reboot, write it here, otherwise this is a good moment to reboot.

If you restored the system to a new drive, and your device names changed (for example from /dev/hda to /dev/sda) then you must adapt the bootloader and the mount points. While still on runlevel 1, edit these files:

/boot/grub/menu.list
/etc/fstab

Update your drive mappings to the new devices there. Grub may be setup with numberish IDs for your drives, then you need the command blkid to read the new identifiers of your disk.

After your system is able to boot and runs again, you can resize your partitions to fill the rest of the new harddisk (if you want that) as described here:

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

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 transferring to a remote machine is:

sudo rsync --delete -azvv -e ssh /home remoteuser@remotehost.remotedomain:./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

rsync has several graphical frontends: grsync, Backup Monitor, QSync, Zynk, rsyncbackup, TKsync

For more options, there is a separate page about rsync

Backup Destination on a Remote Machine

Simple Backup Suite

BackupYourSystem/SimpleBackupSuite

Duplicity

DuplicityBackupHowto

BackupPC

BackupPC

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.

They let you see every change to a file over it's 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.

Related Links

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.

A personal blog listing many open source backup solutions: List of Free Open Source Linux and Ubuntu Backup Software

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.


CategoryBackupRecovery

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