old-www/LDP/intro-linux/html/sect_09_02.html

709 lines
13 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>Moving your data to a backup device</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Introduction to Linux"
HREF="index.html"><LINK
REL="UP"
TITLE="Fundamental Backup Techniques"
HREF="chap_09.html"><LINK
REL="PREVIOUS"
TITLE="Introduction"
HREF="sect_09_01.html"><LINK
REL="NEXT"
TITLE="Using rsync"
HREF="sect_09_03.html"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Introduction to Linux: </TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="sect_09_01.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 9. Fundamental Backup Techniques</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="sect_09_03.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="sect_09_02"
></A
>9.2. Moving your data to a backup device</H1
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="sect_09_02_01"
></A
>9.2.1. Making a copy on a floppy disk</H2
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="sect_09_02_01_01"
></A
>9.2.1.1. Formatting the floppy</H3
><P
>On most Linux systems, users have access to the floppy disk device. The name of the device may vary depending on the size and number of floppy drives, contact your system admin if you are unsure. On some systems, there will likely be a link <TT
CLASS="filename"
>/dev/floppy</TT
> pointing to the right device, probably <TT
CLASS="filename"
>/dev/fd0</TT
> (the auto-detecting floppy device) or <TT
CLASS="filename"
>/dev/fd0H1440</TT
> (set for 1,44MB floppies).</P
><P
>&#13;<B
CLASS="command"
>fdformat</B
> is the low-level floppy disk formatting tool. It has the device name of the floppy disk as an option. <B
CLASS="command"
>fdformat</B
> will display an error when the floppy is write-protected.
</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;<TT
CLASS="prompt"
>emma:~&#62;</TT
> <B
CLASS="command"
>fdformat /dev/fd0H1440</B
>
Double-sided, 80 tracks, 18 sec/track. Total capacity 1440 kB.
Formatting ... done
Verifying ... done
<TT
CLASS="prompt"
>emma:~&#62;</TT
>
</PRE
></FONT
></TD
></TR
></TABLE
><P
>The <B
CLASS="command"
>mformat</B
> command (from the mtools package) is used to create DOS-compatible floppies which can then be accessed using the <B
CLASS="command"
>mcopy</B
>, <B
CLASS="command"
>mdir</B
> and other m-commands.</P
><P
>Graphical tools are also available.</P
><DIV
CLASS="figure"
><A
NAME="AEN9268"
></A
><P
><B
>Figure 9-1. Floppy formatter</B
></P
><DIV
CLASS="mediaobject"
><P
><IMG
SRC="images/formatfloppy.png"></P
></DIV
></DIV
><P
>After the floppy is formatted, it can be mounted into the file system and accessed as a normal, be it small, directory, usually via the <TT
CLASS="filename"
>/mnt/floppy</TT
> entry.</P
><P
>Should you need it, install the <B
CLASS="command"
>mkbootdisk</B
> utility, which makes a floppy from which the current system can boot.</P
></DIV
><DIV
CLASS="sect3"
><H3
CLASS="sect3"
><A
NAME="sect_09_02_01_02"
></A
>9.2.1.2. Using the <B
CLASS="command"
>dd</B
> command to dump data</H3
><P
>The <B
CLASS="command"
>dd</B
> command can be used to put data on a disk, or get it off again, depending on the given input and output devices. An example:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;<TT
CLASS="prompt"
>gaby:~&#62;</TT
> <B
CLASS="command"
>dd if=images-without-dir.tar.gz of=/dev/fd0H1440</B
>
98+1 records in
98+1 records out
<TT
CLASS="prompt"
>gaby~&#62;</TT
> <B
CLASS="command"
>dd if=/dev/fd0H1440 of=/var/tmp/images.tar.gz</B
>
2880+0 records in
2880+0 records out
<TT
CLASS="prompt"
>gaby:~&#62;</TT
> <B
CLASS="command"
>ls /var/tmp/images*</B
>
/var/tmp/images.tar.gz
</PRE
></FONT
></TD
></TR
></TABLE
><P
>Note that the dumping is done on an unmounted device. Floppies created using this method will not be mountable in the file system, but it is of course the way to go for creating boot or rescue disks. For more information on the possibilities of <B
CLASS="command"
>dd</B
>, read the man pages.</P
><P
>This tool is part of the GNU <EM
>coreutils</EM
> package.</P
><DIV
CLASS="note"
><P
></P
><TABLE
CLASS="note"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/note.gif"
HSPACE="5"
ALT="Note"></TD
><TH
ALIGN="LEFT"
VALIGN="CENTER"
><B
>Dumping disks</B
></TH
></TR
><TR
><TD
>&nbsp;</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>The <B
CLASS="command"
>dd</B
> command can also be used to make a raw dump of an entire hard disk.</P
></TD
></TR
></TABLE
></DIV
></DIV
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="sect_09_02_02"
></A
>9.2.2. Making a copy with a CD-writer</H2
><P
>On some systems users are allowed to use the CD-writer device. Your data will need to be formatted first. Use the <B
CLASS="command"
>mkisofs</B
> command to do this in the directory containing the files you want to backup. Check with <B
CLASS="command"
>df</B
> that enough disk space is available, because a new file about the same size as the entire current directory will be created:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;<TT
CLASS="prompt"
>[rose@blob recordables]</TT
> <B
CLASS="command"
>df -h .</B
>
Filesystem Size Used Avail Use% Mounted on
/dev/hde5 19G 15G 3.2G 82% /home
<TT
CLASS="prompt"
>[rose@blob recordables]</TT
> <B
CLASS="command"
>du -h -s .</B
>
325M .
<TT
CLASS="prompt"
>[rose@blob recordables]</TT
> <B
CLASS="command"
>mkisofs -J -r -o cd.iso .</B
>
&#60;--snap--&#62;
making a lot of conversions
&#60;--/snap--&#62;
98.95% done, estimate finish Fri Apr 5 13:54:25 2002
Total translation table size: 0
Total rockridge attributes bytes: 35971
Total directory bytes: 94208
Path table size(bytes): 452
Max brk space used 37e84
166768 extents written (325 Mb)
</PRE
></FONT
></TD
></TR
></TABLE
><P
>The <TT
CLASS="option"
>-J</TT
> and <TT
CLASS="option"
>-r</TT
> options are used to make the CD-ROM mountable on different systems, see the man pages for more. After that, the CD can be created using the <B
CLASS="command"
>cdrecord</B
> tool with appropriate options:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;<TT
CLASS="prompt"
>[rose@blob recordables]</TT
> <B
CLASS="command"
>cdrecord -dev 0,0,0 -speed=8 cd.iso</B
>
Cdrecord 1.10 (i686-pc-linux-gnu) (C) 1995-2001 Joerg Schilling
scsidev: '0,0,0'
scsibus: 0 target: 0 lun: 0
Linux sg driver version: 3.1.20
Using libscg version 'schily-0.5'
Device type : Removable CD-ROM
Version : 0
Response Format: 1
Vendor_info : 'HP '
Identification : 'CD-Writer+ 8100 '
Revision : '1.0g'
Device seems to be: Generic mmc CD-RW.
Using generic SCSI-3/mmc CD-R driver (mmc_cdr).
Driver flags : SWABAUDIO
Starting to write CD/DVD at speed 4 in write mode for single session.
Last chance to quit, starting real write in 0 seconds.
Operation starts.
</PRE
></FONT
></TD
></TR
></TABLE
><P
>Depending on your CD-writer, you now have the time to smoke^H^H^H^H^H eat a healthy piece of fruit and/or get a cup of coffee. Upon finishing the job, you will get a confirmation message:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;Track 01: Total bytes read/written: 341540864/341540864
(166768 sectors).
</PRE
></FONT
></TD
></TR
></TABLE
><P
>There are some graphical tools available to make it easier on you. One of the popular ones is <B
CLASS="command"
>xcdroast</B
>, which is freely available from <A
HREF="http://www.xcdroast.org/"
TARGET="_top"
>the X-CD-Roast web site</A
> and is included on most systems and in the GNU directory. Both the KDE and Gnome desktop managers have facilities to make your own CDs.</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="sect_09_02_03"
></A
>9.2.3. Backups on/from jazz drives, USB devices and other removables</H2
><P
>These devices are usually mounted into the file system. After the mount procedure, they are accessed as normal directories, so you can use the standard commands for manipulating files.</P
><P
>In the example below, images are copied from a USB camera to the hard disk:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;<TT
CLASS="prompt"
>robin:~&#62;</TT
> <B
CLASS="command"
>mount <TT
CLASS="filename"
>/mnt/camera</TT
></B
>
<TT
CLASS="prompt"
>robin:~&#62;</TT
> <B
CLASS="command"
>mount | grep <TT
CLASS="parameter"
><I
>camera</I
></TT
></B
>
/dev/sda1 on /mnt/camera type vfat (rw,nosuid,nodev)
</PRE
></FONT
></TD
></TR
></TABLE
><P
>If the camera is the only USB storage device that you ever connect to your system, this is safe. But keep in mind that USB devices are assigned entries in <TT
CLASS="filename"
>/dev</TT
> as they are connected to the system. Thus, if you first connect a USB stick to your system, it will be on the <TT
CLASS="filename"
>/dev/sda</TT
> entry, and if you connect your camera after that, it will be assigned to <TT
CLASS="filename"
>/dev/sdb</TT
> - provided that you do not have any SCSI disks, which are also on <TT
CLASS="filename"
>/dev/sd*</TT
>. On newer systems, since kernel 2.6, a hotplug system called HAL (Hardware Abstraction Layer) ensures that users don't have to deal with this burden. If you want to check where your device is, type <B
CLASS="command"
>dmesg</B
> after inserting it.</P
><P
>You can now copy the files:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;<TT
CLASS="prompt"
>robin:~&#62;</TT
> <B
CLASS="command"
>cp -R /mnt/camera/* images/</B
>
<TT
CLASS="prompt"
>robin:~&#62;</TT
> <B
CLASS="command"
>umount /mnt/camera</B
>
</PRE
></FONT
></TD
></TR
></TABLE
><P
>Likewise, a jazz drive may be mounted on <TT
CLASS="filename"
>/mnt/jazz</TT
>.</P
><P
>Appropriate lines should be added in <TT
CLASS="filename"
>/etc/modules.conf</TT
> and <TT
CLASS="filename"
>/etc/fstab</TT
> to make this work. Refer to specific hardware HOWTOs for more information. On systems with a 2.6.x kernel or higher, you may also want to check the man pages for <B
CLASS="command"
>modprobe</B
> and <TT
CLASS="filename"
>modprobe.conf</TT
>.</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="sect_09_02_04"
></A
>9.2.4. Backing up data using a tape device</H2
><P
>This is done using <B
CLASS="command"
>tar</B
> (see above). The <B
CLASS="command"
>mt</B
> tool is used for controlling the magnetic tape device, like <TT
CLASS="filename"
>/dev/st0</TT
>. Entire books have been written about tape backup, therefore, refer to our reading-list in <A
HREF="app2.html"
>Appendix B</A
> for more information. Keep in mind that databases might need other backup procedures because of their architecture.</P
><P
>The appropriate backup commands are usually put in one of the <EM
>cron</EM
> directories in order to have them executed on a regular basis. In larger environments, the freely available <A
HREF="http://www.amanda.org"
TARGET="_top"
>Amanda</A
> backup suite or a commercial solution may be implemented to back up multiple machines. Working with tapes, however, is a system administration task beyond the scope of this document.</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="sect_09_02_05"
></A
>9.2.5. Tools from your distribution</H2
><P
>Most Linux distributions offer their own tools for making your life easy. A short overview:</P
><P
></P
><UL
><LI
><P
>SuSE: <SPAN
CLASS="application"
>YaST</SPAN
> now includes expanded backup and restore modules.</P
></LI
><LI
><P
>RedHat: the <SPAN
CLASS="application"
>File Roller</SPAN
> tool provides visual management of (compressed) archives. They seem to be in favour of the X-CD-Roast tool for moving backups to an external device.</P
></LI
><LI
><P
>Mandrake: X-CD-Roast.</P
></LI
><LI
><P
>Most distributions come with the BSD <B
CLASS="command"
>dump</B
> and <B
CLASS="command"
>restore</B
> utilities for making backups of <EM
>ext2</EM
> and <EM
>ext3</EM
> file systems. This tool can write to a variety of devices and literally dumps the file(s) or file system bit per bit onto the specified device. Like <B
CLASS="command"
>dd</B
>, this allows for backing up special file types such as the ones in <TT
CLASS="filename"
>/dev</TT
>.</P
></LI
></UL
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="sect_09_01.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sect_09_03.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Introduction</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="chap_09.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Using rsync</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>