• Tidak ada hasil yang ditemukan

Moving your data to a backup device

Dalam dokumen Introduction to Linux - Mirror UNPAD (Halaman 157-161)

Chapter 9. Fundamental Backup Techniques

9.2. Moving your data to a backup device

9.1.1.4. Java archives

The GNU project provides us with the jar tool for creating Java archives. It is a Java application that combines multiple files into a single JAR archive file. While also being a general purpose archiving and compression tool, based on ZIP and the ZLIB compression format, jar was mainly designed to facilitate the packing of Java code, applets and/or applications in a single file. When combined in a single archive, the components of a Java application, can be downloaded much faster.

Unlike tar, jar compresses by default, independent from other tools − because it is basically the Java version of zip. In addition, it allows individual entries in an archive to be signed by the author, so that origins can be authenticated.

The syntax is almost identical as for the tar command, we refer to info jar for specific differences.

tar, jar and symbolic links

One noteworthy feature not really mentioned in the standard documentation is that jar will follow symbolic links. Data to which these links are pointing will be included in the archive. The default in tar is to only backup the symbolic link, but this behavior can be changed using the −h to tar.

9.1.1.5. Transporting your data

Saving copies of your data on another host is a simple but accurate way of making backups. See Chapter 10 for more information on scp, ftp and more.

In the next section we'll discuss local backup devices.

Graphical tools are also available.

Figure 9−1. Floppy formatter

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 /mnt/floppy entry.

Should you need it, install the mkbootdisk utility, which makes a floppy from which the current system can boot.

9.2.1.2. Using the dd command to dump data

The dd 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:

gaby:~> dd if=images−without−dir.tar.gz of=/dev/fd0H1440 98+1 records in

98+1 records out

gaby~> dd if=/dev/fd0H1440 of=/var/tmp/images.tar.gz 2880+0 records in

2880+0 records out

gaby:~> ls /var/tmp/images*

/var/tmp/images.tar.gz

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 dd, read the man pages.

This tool is part of the GNU coreutils package.

Dumping disks

The dd command can also be used to make a raw dump of an entire hard disk.

9.2.2. Making a copy with a CD−writer

On some systems users are allowed to use the CD−writer device. Your data will need to be formatted first.

Use the mkisofs command to do this in the directory containing the files you want to backup. Check with df that enough disk space is available, because a new file about the same size as the entire current directory will be created:

[rose@blob recordables] df −h .

Filesystem Size Used Avail Use% Mounted on /dev/hde5 19G 15G 3.2G 82% /home [rose@blob recordables] du −h −s .

325M .

[rose@blob recordables] mkisofs −J −r −o cd.iso .

<−−snap−−>

making a lot of conversions

<−−/snap−−>

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)

The −J and −r 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 cdrecord tool with appropriate options:

[rose@blob recordables] cdrecord −dev 0,0,0 −speed=8 cd.iso 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.

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:

Track 01: Total bytes read/written: 341540864/341540864 (166768 sectors).

There are some graphical tools available to make it easier on you. One of the popular ones is xcdroast, which is freely available from the X−CD−Roast web site 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.

9.2.3. Backups on/from jazz drives, USB devices and such

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.

In the example below, images are copied from a USB camera to the hard disk:

robin:~> mount /mnt/camera robin:~> mount | grep camera

/dev/sda1 on /mnt/camera type vfat (rw,nosuid,nodev)

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 /dev as they are connected to the system. Thus, if you first connect a USB stick to your system, it will be on the /dev/sda entry, and if you connect your camera after that, it will be assigned to /dev/sdb − provided that you do not have any SCSI disks, which are also on /dev/sd*. 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 dmesg after inserting it.

You can now copy the files:

robin:~> cp −R /mnt/camera/* images/

robin:~> umount /mnt/camera

Likewise, a jazz drive may be mounted on /mnt/jazz.

Appropriate lines should be added in /etc/modules.conf and /etc/fstab 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 modprobe and modprobe.conf.

9.2.4. Backing up data using a tape device

This is done using tar (see above). The mt tool is used for controlling the magnetic tape device, like /dev/st0. Entire books have been written about tape backup, therefore, refer to our reading−list in

Appendix B for more information. Keep in mind that databases might need other backup procedures because of their architecture.

The appropriate backup commands are usually put in one of the cron directories in order to have them

executed on a regular basis. In larger environments, the freely available Amanda 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.

9.2.5. Tools from your distribution

Most Linux distributions offer their own tools for making your life easy. A short overview:

SuSE: YaST now includes expanded backup and restore modules.

RedHat: the File Roller 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.

Mandrake: X−CD−Roast.

Most distributions come with the BSD dump and restore utilities for making backups of ext2 and ext3 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 dd, this allows for backing up special file types such as the ones in /dev.

Dalam dokumen Introduction to Linux - Mirror UNPAD (Halaman 157-161)