6.3.2. How Does It Work?

The growisofs command is part of the package dvd+rw- tools , which was originally intended for use with DVD+RW media. Since the original design, it has grown to include support for all DVD media formats. It operates as a frontend to the mkisofs command, which produces a filesystem in the ISO 9660 format that is the standard for optical media, and then writes the mkisofs output to the disc burner.

ISO 9660 is unfortunately limited to eight-character filenames with a three-character extension. The Rock Ridge (RR) extension adds support for long filenames, user and group ownership, and permission mode under Linux; Joliet extensions add similar support for the Windows operating systems. Using the -JR option to growisofs causes the created disk to be compatible with both Rock Ridge and Joliet.

mkzftree makes a recursive copy of a directory structure, compressing any files that would benefit from compression during the copy process. The resulting directory structure can be passed to mkisofs with the -z option, which will cause mkisofs to create additional Rock Ridge records with information about the data compression used. These records in turn enable the kernel's filesystem layer to decompress the files on the fly when reading them from disc.

When backing up to tape, tar converts a directory structure to a continuous stream of bytes. A short header contains the pathname, ownership, permissions modes, size, and timestamps for a file, followed by the data for that file; this is repeated for each file in the archive.

The z option to tar causes it to start gzip and process all data through it. As an alternative, the j option will process the archive stream through bzip2 , which may offer better compression in some circumstances.

6.3.3. What About...

6.3.3.1. ...using LVM snapshots in a backup script?

You can simply place the appropriate vgcreate and mount commands at the start of your backup script, and umount and vgremove commands at the end of the script.

Here is a slightly fancier version of the DVD backup script, which accepts a list of vg / lv pairs and creates a compressed DVD backup. Set the LVLIST and SNAPSIZE variables to whatever values you wish to use:

#!/bin/bash

#

# backup-dvd :: backup selected directories to a compressed DVD

#

# List of the vg/lv to be backed up

LVLIST='main/home main/var'

# Amount of space to use for snapshots

SNAPSIZE='1G'

# Create timestamp file

(

rm -f /system-*

touch /system-$(hostname)

# Make directory for compressed backup tree

rm -rf /tmp/zftree

mkdir /tmp/zftree

RESULT=0

for VGLV in $LVLIST

do

 echo '========= Processing $VGLV...'

 # Get information about the vg/lv

 VG=$(echo $VGLV|cut -f1 -d/)

 LV=$(echo $VGLV|cut -f2 -d/)

 SNAPNAME='${LV}-snap'

 OLDMOUNT=

 $(grep '^/dev/${VGLV}' /etc/fstab|tr ' ' ' '|tr -s ' '|cut -f2 -d' ')

 NEWMOUNT='/mnt/snap${OLDMOUNT}'

 # Create a snapshot

 lvcreate -s $VGLV --name $SNAPNAME --size $SNAPSIZE

 RESULT=$(( $? + $RESULT ))

 # Mount the snapshot

 mkdir -p $NEWMOUNT

 mount -o ro /dev/${VG}/${SNAPNAME} ${NEWMOUNT}

 RESULT=$(( $? + $RESULT ))

 # Place it in the zftree

 mkdir -p /tmp/zftree$(dirname $OLDMOUNT)

 mkzftree ${NEWMOUNT} /tmp/zftree${OLDMOUNT}

 RESULT=$(( $? + $RESULT ))

 # Unmount the snapshot

 umount $NEWMOUNT

 # Release the snapshot

 lvremove -f ${VG}/${SNAPNAME}

done

if [ '$RESULT' -eq 0 ]

then

 # Burn the DVD

Вы читаете Fedora Linux
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату