You are on page 1of 19

Offline File Storage

Offline File Storage

Module 12

Offline File Storage

Introduction Backup is usually done by first collecting all the data in a single archive file, which can be compressed using the compression tools. Topic Storing files to Media

Offline File Storage

Storage files to Media


Backing up of a system is the most major task to be performed by a

system administrator.
Computers have the major advantage of storing the data, which makes

it significant.
Backups are important because of the possibility of loss of data. The possibility of data loss can be by: File system corruption Accidental removal of files Hardware failures System crash

Contd

Offline File Storage

Storage files to Media


Backup Media The following are some of the methods of back up through media
floppy disks
Tapes removable hard disks rewritable CD-ROMs

Backup tools tar dd Dump cpio


Contd

Offline File Storage

Storage files to Media


Backup using tar command An archiving program designed to store and extract files from an archive file known as a tarfile. The tar is the most commonly used command for the backup.

tar options
tar cvf (creating the tar file)
tar tvf (listing the contents of tar file) tar xvf (extracting the contents of tar file)
where,

c create t list x extract v verbose f file

Contd

Offline File Storage

Storage files to Media


Backup using dd command
dd copies a file from source to destination. It copies an input file (if) file and sends the result to the output file (of) which converts and formats according to the options. Syntax # dd if=<source name> of=<destination name>
Example dd if=bootdisk.img of=/dev/fd0

Contd

Offline File Storage

Storage files to Media


Backup using dump/restore command dump and restore commands are the two different programs that are included in the dump package. These files are copied to the given disk, tape or other storage medium for protection.

Syntax dump - <dump levels> - <options> <destination name> <source name>

Contd

Offline File Storage

Storage files to Media


Example: dump -0 f /home_dumps/mydumps /home where, -0 - dump level (full backup) -f - write a backup to file

Contd

Offline File Storage

Storage files to Media


Backup using restore command

The restore command is used to view and restore the dump file. Syntax: # restore - <options> <file name> Example: restore if mydumps
where,

-i is interactive restoration -f is read backup from file

Contd

Offline File Storage

Storage files to Media


Backup using cpio command

The cpio command is a tool for creating and extracting archives, or copying files from one place to another, which contains other files and information about them, such as their file name, owner, timestamps, and access permissions.
It handles a number of cpio formats as well as reading and writing tar files. The archive can be another file on the disk, a magnetic tape, or a pipe.

Contd

Offline File Storage

Storage files to Media


cpio has three operating modes.

copy-out mode, cpio copies files into an archive.


copy-in mode, cpio copies files out of an archive or lists the archive contents. copy-pass mode, cpio copies files from one directory tree to another, combining the copy-out and copy-in steps without actually using an archive.

Contd

Offline File Storage

Storage files to Media


Syntax for creating the cpio file find (source file name) | cpio (options) > (target file name) Example:
find file1 | cpio -o > file1_back.cpio

Syntax for extracting the cpio file


cat <source file name> | cpio (options)

Example:
cat file1_back.cpio | cpio idvm where,

d make directories i extract m modification time o create v verbose

Contd

Offline File Storage

Storage files to Media


Compression tools

Zip zip is a compression and file packaging utility. The program is useful for packaging a set of files for distribution, archiving files and saving disk space by temporarily compressing unused files or directories. The zip program puts one or more compressed files into a single zip archive, along with information about the files. An entire directory structure can be packed into a zip archive with a single command. Syntax zip <new file> <source file> Example: zip install install.log
Contd

Offline File Storage

Storage files to Media


unzip unzip will list, test, or extract files from a zip archive, commonly found on MS-DOS systems. The default behavior (with no options) is to extract into the current directory and subdirectories all files from the specified zip archive.

Syntax unzip <zipfile> Example: unzip install.zip

Contd

Offline File Storage

Storage files to Media


Gzip By default, gzip keeps the original file name and timestamp in the compressed file. These are used when decompressing the file with the N option. The main advantage of gzip over compress is it has a better compression capacity than other compression tools.

Syntax gzip <filename> Example gzip install.log

Contd

Offline File Storage

Storage files to Media


Gunzip gunzip decompress the files created by gzip. It takes a list of files on its command line and replaces each file ending with .gz, -gz, .z, -z, _z or .Z and which begins with the correct number with an uncompressed file without the original extension. gunzip also recognizes the special extensions .tgz and .taz as shortcuts for .tar.gz and .tar.Z respectively. Syntax gunzip <filename.gz>

Example: gunzip install.log.gz


Contd

Offline File Storage

Storage files to Media


Bzip2 bzip2 is a block-sorting file compressor. It expects a list of file names to accompany the command-line tools. Each file is replaced by a compressed version of itself, with the name original_name.bz2. Each compressed file has the same modification date, permissions and when possible ownership as the corresponding original, so that these properties can be correctly restored at decompression time.

Syntax bzip2 <filename> Example: bzip2 install.log


Contd

Offline File Storage

Storage files to Media


Bunzip2 bunzip2 (or bzip2 -d) decompresses all specified files. bzip2 attempts to guess the filename for the decompressed file from that of the compressed file. If the file does not end in one of the recognized endings, .bz2, .bz, .tbz2 or .tbz, bzip2 gives an error message that it cannot guess the name of the original file, and uses the original name with .out.

Syntax bunzip <filename.bz2> Example: bunzip install.log.bz2

Offline File Storage

Lab Exercise
Backup any desired directory using tar command

Compress the file mydata from the data directory and uncompress into

a new directory by name backup using zip and unzip commands


Backup the /tmp directory into a new directory by name tmp_backup

using dump command