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

  • Machines and Hardware Fail – Computing devices are tested and made for reliability but, they may fail and may be without any alert for same.
  • Humans Make Mistakes – People are not perfect and can easily overlook an important step in a process and accidentally delete data or enter the wrong data.
  • Nature is Unpredictable – Events like floods, typhoon, earthquake can severely affect computing devices.
  • Malware and Unwanted programs – Unwanted program can be accidentally downloaded or copied to device, which may corrupt the stored data.

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

  • Normal/full backups – All files that have been selected are backed up.
  • Differential backups – It is designed to create backup copies of files that have changed since the last normal backup.
  • Incremental backups – It is designed to create backups of files that have changed since the most recent normal or incremental backup. Instead of copying the whole file, only the change is backed up.
  • Daily backups Designed to back up files using the modification date on the file itself. If a file has been modified on the same day as the backup, the file will be backed up.

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.

  • Recovery time objective (RTO): How fast should data be recovered? Can you continue to operate if data recovery is not recovered for a day, a week, etc?
  • Recovery point objective (RPO): How much data can be lost. Can you lose two hours, two days or two weeks of data?

Backup Methods

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

  • manual – Manual backup would be initiated on a schedule by the user and is the most common method for home users to backup their files. This method is also the least reliable.
  • local automated – Automated backups that target a hard drive or tape drive attached to the physical box being backed up fall into this category. Advanced home users and small businesses will often use this method.
  • remote automated – Automated backups that target a hard drive, tape drive or virtual tape library (VTL) over the network fall into this backup. This type of backup is often used by businesses that have money they can dedicate to the process of backup. As the organization becomes more mature they may even stage the backup on multiple mediums and increase the distance between backup and production systems.

Linux records three different times for each file:

  • mtime – modification time; this value is changed when the contents of the file is changed. If you are implementing incremental or differential backups this is important
  • atime – access time; the value of this is changed when the file is accessed. The atime can also change when a backup utility or script has read the file as well as when a user has reads the file.
  • ctime – change time; the value is updated whenever the attributes of the file change. This can be ownership or permission.

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:

  • Restore many single files
  • Restore an older version of a file
  • Restore an entire folder
  • Restore an entire drive and compare the checksum

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

  • asf – The tape is positioned at the beginning of the count file. Positioning is done by first rewinding the tape and then spacing forward over count filemarks.
  • rewind – Rewind the tape.
  • offline, rewoffl, eject – Rewind the tape and, if applicable, unload the tape.
  • erase – Erase the tape.
  • status – Print status information about the tape unit. (If the density code is “no translation” in the status output, this does not affect working of the tape drive.)
  • load – (SCSI tapes) Send the load command to the tape drive. The drives usually load the tape when a new cartridge is inserted. The argument count can usually be omitted. Some HP changers load tape n if the count 10000 + n is given (a special funtion in the Linux st driver).
  • lock – (SCSI tapes) Lock the tape drive door.
  • unlock – (SCSI tapes) Unlock the tape drive door.

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

  • -f Used to specify the backup or dump file
  • -C Used to compare dump-file with original file
  • -i Restore in Interactive mode
  • -v Displays Verbose Information
  • -e Exclude inode while making backup

Commands used in interactive mode:

  • ls List the files and directories in backup file
  • add Add files in dump-file to current working directory
  • cd Changes the directory
  • pwd Displays the current working directory
  • extract Extract the files from the dump
  • quit Quit from the interactive mode

Example

  • To restore file and directories from backup-file –     restore -if databack
  • To compare and display any dump-file with the original file – restore -Cf databack

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:

  • -A, –catenate, –concatenate append tar files to an archive
  • -c, –create create a new archive
  • -d, –diff, –compare find differences between archive and file system
  • -r, –append append files to the end of an archive
  • -t, –list list the contents of an archive
  • -u, –update only append files that are newer than the existing in archive
  • -x, –extract, –get extract files from an archive
  • –delete delete from the archive (not for use on mag tapes!)

Options

  • -C, –directory DIR change to directory DIR
  • -f, –file [HOSTNAME:]F use archive file or device F (default “-“, meaning stdin/stdout)
  • -j, –bzip2 filter archive through bzip2, use to decompress .bz2 files
  • -p, –preserve-permissions extract all protection information
  • -v, –verbose verbosely list files processed
  • -z, –gzip, –ungzip filter the archive through gzip

Examples

  • tar -xvf foo.tar – verbosely extract foo.tar
  • tar -xzf foo.tar.gz – extract gzipped foo.tar.gz
  • tar -cjf foo.tar.bz2 bar/ – create bzipped tar archive of the directory   bar   called
  • tar.bz2 – tar -xjf foo.tar.bz2 -C bar/ – extract bzipped foo.tar.bz2 after changing directory to bar
  • tar -xzf foo.tar.gz blah.txt – extract the file blah.txt from foo.tar.bz2

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:

  • Amanda
  • Amanda-client
  • Amanda-server
  • Gnuplot

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

Share this post
[social_warfare]
DHCP
Internet Services

Get industry recognized certification – Contact us

keyboard_arrow_up