Site icon Tutorial

Backups

Certify and Increase Opportunity.
Be
Govt. Certified Linux Administrator

It is the activity of copying or archiving files and folders for the purpose of being able to restore them in case of data loss. Data loss can be caused by many things ranging from computer viruses to hardware failures to file corruption to fire, flood, or theft (etc).

Need

Data is the most important aspect of computing devices especially mobile. The operating system can be reinstalled and so can applications, but it may be difficult or impossible to recreate original data.

It is essential to always back up important information and have a plan for recovering from a system failure. An attacker could crash a computer’s operating system or data may be corrupted or wiped out by a hardware problem. Computers can be lost, stolen, or destroyed in a fire or other catastrophe.

You should back up your personal or critical work data on a regular basis. This means copying your files over to a protected system that you can access when those files are needed.

Main reasons to backup are

Types of Backup

There are many techniques for backing up files. The techniques to use depend on the type of data you’re backing up, how convenient you want the recovery process to be, and more. The types of backups are

There are many methods to provide backup and recovery; choosing the best process for you or your business will have to take several factors in to account.

Backup Methods

Depending on your budget and specific RTO and RPO you can choose from manual, local automated, or remote automated.

Linux records three different times for each file:

Recovery

It is crucial that your backups are tested by restoring them. Here are some tests you should do to ensure that you can recover from a disaster:

Linux Backup Tools

There are many tools that can be used to make backups. The traditional UNIX tools used for backups are tar, cpio, and dump. In addition, there are large number of third party packages (both freeware and commercial) that can be used. The choice of backup medium can affect the choice of tool.

tar and cpio are similar, and mostly equivalent from a backup point of view. Both are capable of storing files on tapes, and retrieving files from them. Both are capable of using almost any media, since the kernel device drivers take care of the low level device handling and the devices all tend to look alike to user level programs. Some UNIX versions of tar and cpio may have problems with unusual files (symbolic links, device files, files with very long pathnames, and so on), but the Linux versions should handle all files correctly.

dump is different in that it reads the filesystem directly and not via the filesystem. It is also written specifically for backups; tar and cpio are really for archiving files, although they work for backups as well. Reading the filesystem directly has some advantages. It makes it possible to back files up without affecting their time stamps; for tar and cpio, you would have to mount the filesystem read−only first. Directly reading the filesystem is also more effective, if everything needs to be backed up, since it can be done with much less disk head movement. The major disadvantage is that it makes the backup program specific to one filesystem type; the Linux dump program understands the ext2 filesystem only. dump also directly supports backup levels with tar and cpio this has to be implemented with other tools.

mt and st command

The mtcommand is used to scan, rewind, and eject magnetic tapes if you have an IDE drive. If you have a SCSI tape drive, the st command performs the same functions.

Syntax

mt [-h] [-f device] operation [count] [arguments…]

mt performs the given operation, on a tape drive. The commands can also be listed by running the program with the -h option. The version of mt is printed with the -v or –version option. The path of the tape device to operate on can be given with the -f or -t option. If neither of those options is given, and the environment variable TAPE is set, it is used. Otherwise, a default device defined in the file /usr/include/sys/mtio.h is used.

Some operations optionally take an argument or repeat count, which can be given after the operation name and defaults to 1.

You must be root in order to access the tape drives. As root, you can test a new magnetic tape by inserting it into the tape drive and then using the following command

mt –f /dev/rft0 rewind

This command should rewind the magnetic tape. You can also format the magnetic tape with the command

ftformat –f /dev/rft0

The available operations

The st driver provides the interface to a variety of SCSI tape devices. Currently, the driver takes control of all detected devices of type lqsequential-access.rq The st driver uses major device number 9.

Each device uses eight minor device numbers. The lower-most five bits in the minor numbers are assigned sequentially in the order of detection. The minor numbers can be grouped into two sets of four numbers: the principal (auto-rewind) minor device numbers, n, and a lqno-rewindrq device numbers, (n+ 128). Devices opened using the principal device number will be sent a REWIND command when they are closed. Devices opened using the lqno-rewindrq device number will not. (Note that using an auto-rewind device for positioning the tape with, for instance, mt does not lead to the desired result: the tape is rewound after the mt command and the next command starts from the beginning of the tape).

dump command

The dump package consists of several commands for doing backup and restoration of the file system. The dump command is used to do backups of either entire partitions or individual directories. The restore command is used to restore an entire partition, individual directories, or individual files.

The first argument to the dump command is a list of options. Following that are all of the arguments required by the various options in the same order as the options were specified. The last argument is the file system to back up.

The available dump options, are

Option Meaning
B The number of records per volume.
b The number of kilobytes per dump record.
h The dump level at which to use nodump flags.
f Name of file or device to write to.
d Tape density.
n Tell dump to send a message when done.
s Length of dump tape.
u Record the date of this dump in /etc/dumpdates.
T Add only files older than the given time.
W List the file systems that need to be backed up.
w List individual files that need to be backed up.
0-9 Specify a dump level of 0 through 9.

Example

dump 0uf /dev/rft0 /dev/hda3

This command specifies that the file system on /dev/hda3 should be backed up on the magnetic tape on device /dev/rft0. It specifies that the backup should use backup level 0 (full backup) and write the time of the backup to the /etc/dumpdates file.

Restore command

The restore command is used to retrieve files from the backups created with dump. You can use restore to restore an entire file system or you can use it to interactively select which files you want to restore. The syntax for the restore command is the same as for the dump command, although it has different options.

Options

Commands used in interactive mode:

Example

tar command

The GNU version of the tar archiving utility. Multi-volume archiving is an automated process in which tar prompts for new media to be inserted whenever it runs out of space. The tar program is a utility originally designed for making magnetic tape backups, but is useful for any kind of archiving purpose. When making archives, it is important to specify a leading ./ for files. That creates a relative path, which will be necessary when restoring the files later. The tar command requires one command option followed by any number of optional options.

Syntax

tar <operation> [options]

Operations:

[-]A –catenate –concatenate [-]c –create [-]d –diff –compare [-]r –append [-]t –list [-]u –update [-]x –extract –get

–delete

Common Options:

-C, –directory DIR

-f, –file F

-j, –bzip2

-p, –preserve-permissions

-v, –verbose

-z, –gzip

tarfile may be made on a tape drive, however, it is also common to write a tarfile to a normal file. The first argument to tar must be one of the options Acdrtux, followed by any optional functions. The final arguments to tar are the names of the files or directories which should be archived. The use of a directory name always implies that the subdirectories below should be included in the archive. One of the following options must be used:

Options

Examples

Amanda

The AMANDA (Advanced Maryland Automatic Network Disk Archiver) package is a set of tools for doing backups of multiple machines over the network. Using Amanda, you can configure your Red Hat Linux machine to be a backup server for the other machines in the network, including Windows systems. Amanda is included with Red Hat Linux 7.2. To use Amanda you should install the following packages:

You need to install the Amanda-server and gnuplot packages only on the machine that is going to be the backup server. However, you must install Amanda-client on any machine that you want to back up using Amanda. You must install the base Amanda package on both the client and server machines. The Amanda package contains several commands,

Command Use
Amdump Normally executed periodically by a cron job, this utility is run on the Amanda server. It requests backups from the various Amanda clients.
Amflush If amdump has trouble writing backups to tape, they are kept in temporary storage space on disk until the problem is corrected. After the problem is fixed, this command is run to write the data in the temporary storage space to the tapes.
Amcleanup If the Amanda server crashes during the running of amdump, this utility should be run to cleanup after the interrupted amdump.
Amrecover This utility provides a way to select which tapes should be used to recover files.
Amrestore This utility is used to restore individual files or directories or entire partitions from Amanda backups.
Amlabel This utility is used to write an Amanda label onto a tape. You must use this command to label tapes before they can be written to with amdump.
Amcheck This utility should be run before amdump to verify that the correct tape is in the drive.
Amadmin This utility does various administrative tasks.
Amtape This utility is used for low-level tape control, such as loading and ejecting disks.
Amverify This utility checks Amanda tapes for errors.

Back to Tutorial

Apply for Linux Administration Certification Now!!

http://www.vskills.in/certification/Certified-Linux-Administrator

Exit mobile version