Linux Backyp and recovery

Before we can talk about backups, we need to introduce the tools
used to archive files on UNIX systems.
Linux Based Networks
Topic Heading Class Meeting # Slide : 4


Usingtar.
The tar command is most often used to archive files. Its
command syntax is
where optionsis the list of commands and options for tar, and
filesis the list of files to add or extract from the archive.
For example, the command
# tar options files
# tar cvf backup.tar /etc
Linux Based Networks
Topic Heading Class Meeting # Slide : 5



# tar cvf backup.tar /etc
packs all of the files in /etc into the tar archive backup.tar.
The first argument to tar, “cvf”
c tells tar to create a new archive file.
v forces tar to use verbose mode, printing each file name as it is
archived.
f option tells tar that the next argument, backup.tar, is the
name of the archive to create.
The rest of the arguments to tar are the file and directory names
to add to the archive.
Linux Based Networks
Topic Heading Class Meeting # Slide : 6


# tar xvf backup.tar
Will extract the tar file backup.tar in the current directory.
Old files with the same name are overwritten when extracting files
into an existing directory.
Remember!!!
Before extracting tar files it is important to know where the files
should be unpacked.
Linux Based Networks
Topic Heading Class Meeting # Slide : 7


# tar tvf backup.tar
can be used to display a listing of the archive's files without
extracting them.
You can see what directory the files in the archive are stored
relative to, and extract the archive in the correct location.
Linux Based Networks
Topic Heading Class Meeting # Slide : 8



gzip
Unlike archiving programs for MS-DOS, tar does not automatically
compress files as it archives them. If you are archiving two, 1-
megabyte files, the resulting tar file is two megabytes in size. The
gzip command compresses a file (it need not be a tar file). The
command
compresses backup.tar and leaves you with backup.tar.gz, a
compressed version of the file.
The -9 switch tells gzip to use the highest compression factor.
# gzip –9 backup.tar
Linux Based Networks
Topic Heading Class Meeting # Slide : 9



gunzip
The result is backup.tar.gz. To unpack this file, use the reverse
commands
Always make sure that you are in the correct directory
before unpacking a tar file.
# gunzip backup.tar.gz
Linux Based Networks
Topic Heading Class Meeting # Slide : 10



Putting them together.
1. Here, we send the tar file to ``-'', which stands for tar's
standard output.
2. This is piped to gzip, which compresses the incoming tar file.
3. The result is saved in backup.tar.gz.
4. The -c option tells gzip to send its output to standard output,
which is redirected to backup.tar.gz.
# tar cvf - /etc gzip –9c > backup.tar.gz
Linux Based Networks
Topic Heading Class Meeting # Slide : 11



Unpack this Archive
A single command to unpack this archive would be
Again, gunzip uncompresses the contents of backup.tar.gz and
sends the resulting tar file to standard output. This is piped to tar,
which reads ``-'', this time referring to tar's standard input.

Popular posts from this blog

Open Blocked Web Site in any Country

OPERATION OF STENO PHONE