Week 9 - Managing Backup and Recovery Flashcards

1
Q

System backup

A

Copies files and directories to an archive

Use to restore data in case of system failure of data loss and corruption

Most common backup medium is tape

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Archive

A

File containing many other files, each of which is still identified by its file name, owner, permissions, and timestamp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

System backups in Linux

Directories to include in regular backups

A

/etc contains core configuration files, security files, network configuration files, user and group
information, etc

/home each user has a /home directory

/opt software and packages added after the default installation

/root root user’s home directory

/var system specific information that changes while the system is running normally

/srv server scripts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Tar Utility

A

Tar (tape archive) utility

Archives files
- creates archives by combining multiple files and directories into a single file
- originally designed to store files on magnetic tape
- now used to store files on a tape, hard disk, CD/DVD, or even on a network

Extracts files
- unpack members of an archive making them available to the file system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Common tar options

A

-c or –create
creates an archive file

-t or –list
Lists an archive’s contents

-x or –extract
Extracts an archive’s contents

-f or –file
Specifies the archive’s file name and location

-v or –verbose
Displays details about copying files to and extracting files from archives

-z or –gzip, –unzip
Filters an archive through gzip

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Members

A

– Different from files
– Can be viewed only with the tar command’s t option
– Can extract all/some members from an archive
* e.g. When a user deletes a file accidentally

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  • r or –append
A

Adds files to existing archive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

-u or –update

A

Compares the date and time of a member with the date and time of the file with the same name. If the file was modified after the archive was created, its newer version is added to the archive.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

-A or –concatenate

A

Similar to append option but adds one archive to another archive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

–delete

A

removes specific members from a tar archive. This option doesn’t have a short name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

-d or –compare

A

compares specified members with files in the file system having the same name and reports difference in file size, mode, owner, modification date and contents

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

–mode

A

changes a member’s permissions in an archive with number or symbolic notation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

–mtime

A

changes a member’s modification date in the tar archive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

–owner

A

changes the member’s owner in the tar archive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

–group

A

similar to –owner, except it’s user to change member’s group instead of owner

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Full backup

A

Archive of all files on file system

Never perform a full backup while users are accessing the system - tar file could be corrupted if files are modified during backup process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

tar command for full backup

A

tar -cvf backup0.tar -V “Comment” –listed-incremental =/home/backup.snap *

creates full backup of current directory

-cvf creates archive called backup0.tar
-v labels archive with the text between quotation marks
–listed-incremental creates a snapshot file named backup.snap which is used during incremental backups to determine which files have changed since the last backup
* what files to backup

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Incremental backups

A

Archive containing only files modified since the last backup

– Companies have different backup strategies,
depending on their needs
– Incremental backup each night, full backup weekend
– Full Backup each night

  • Syntax for creating an incremental backup
    – Same as the command for full backups
    – If the snapshot file already exists, the tar utility
    examines it to determine whether any files have
    changed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

-V or –label

A

Adds volume header to tar file. Volume header is a digital label used to describe file. View volume header with -t option

20
Q

-w or –verify

A

verifies files have been included in archive correctly

21
Q

-g or –listed-incremental

A

Forces tar to archive only files that have been modified since last backup (full or incremental) by analysing a snapshot file.
The snapshot file is given as an argument to the –listed-incremental option so that tar utility knows which files have been changed, added or deleted since last backup.

22
Q

–no-check-device

A
23
Q

–no-check-device

A

When a device number changes (can happen when upgrading kernel version) an incremental backup might backup files that haven’t been changed. This option prevents this from happening by forcing tar utility to not rely on device number when preparing for incremental backup.

24
Q

–check-device

A

default option; necessary only when you want to undo –no-check-device option

25
Q

Cpio Utility

A

Copy in/out utility
- Uses results of ls or find command to generate files to be archived

Operates in 3 modes
- Copy-out, cpio created an archive from the output of ls or find commands
-Copy-in, extracts files from an archive
-Copy-pass, copies files from one directory to another

26
Q

Input redirection

A

Default standard input - keyboard
< symbol redirects input instead of getting input from keyboard, can get input from file

27
Q

Output redirection

A

default standard output, screen e.g. type ls and result is output to screen

Output redirection operators redirect command’s output
> redirects output to a file

> file redirection
| pipe redirection

redirects output of one command and sends it ass input to another commands

28
Q

ls > myfile

A

redirect ls command’s output to the myfile instead of displaying the output on screen

29
Q

ls | more

A

redirect ls output to more command

30
Q

Copy-Out Mode

A

cpio - copy in/out utility
Uses results of ls or find command to generate files to be archived

-o or –create
creates archives by accepting output of ls or find as input for an archive

e.g. ls | cpio -o > files.cpio
results of ls command used to determine which files to archive in files.cpio

31
Q

Copy-In Mode

A

Extract an archive
use standard input redirection symbol < to extract the archive members

-i extracts fies from a cpio archive

-v lists files as they are being extracted

32
Q

Copy-Pass Mode

A

Copy files and directories from one directory and paste them in another directory
- without actually creating an archive

Not practical option for option for backups
- Does almost same as cp command

Cpio utility
- Preserves modification times and ownership

-p copy files from one directory tree to another

33
Q

Compression

A

Reduces size of data to store information in less space

Every GB of data costs money

Compress data to:
- Save storage space
- Make it fit on removable media
- Transfer it across network faster

Most common compression utility gzip
bzip2 also available

34
Q

The gzip Utility

A

File compressed with gzip has:
– Extension .gz
–Same file permissions, ownership, and modification time as the original file
– Much smaller file size

  • Compression ratio
    – Defines by how much a file is reduced after compressing it
    – Text files are typically reduced by 60% to 70% with compression
    – -v option: view compression ratio

gzip is built into tar
- Use -z option to enable gzip
- Compress an archive as you create it

35
Q

Scheduling Backups

A

Configure Automatic system backups
– Backing up is a chore
– Management can often prioritize other work
– 75% of data loss is human error related
– Vital areas of software production, software deployment, data warehousing etc.

36
Q

CRON (Command Run ON)

A

Automatic scheduling and execution of system backups
– Schedule during off hour where fewer people are logged in to the system
– Less disruption in service
- Use CRON

37
Q

CRON daemon (crond)

A

System daemon
Uses a configuration file called a cron table to schedule commands that run at specified times

Cron table has 6 fields
-Fields used to specify time to run task and task to be run

          • command to be executed
            minute (0-59)
            hour (0-23)
            day of month (1-31)
            month (1-12)
            day of week (0-6) Sunday = 0
38
Q

Cron daemon uses two types of cron tables

A

– User cron table in /var/spool/cron/tabs
– System cron table in /etc/crontab
* Users use the user cron table to schedule tasks
* System uses the system cron table to schedule system tasks

39
Q

User Cron tables

A

Every user (including root) on an Linux system has a cron table
* crontab command
– Create, delete, and list cron tables

40
Q

crontab command options

A

-e opens vim editor to edit current user’s cron table. If cron table doesn’t exist, a blank table is created for you to edit.
-u specifes name of user whose cron table is to be edited
-l displays current user’s cron table
-r removes current user’s cron table

41
Q

Displaying contents of text file

A

List a file’s contents without actually opening file in text editor
cat and tic
head and tail
more and less

42
Q

The cat and tic commands

A

cat (concatenation) command
– Displays an entire file’s contents at once
– Typically used to display the contents of a small text file
–Can be used to display the contents of multiple files at once
* -n option
– Display line numbers in a text file:
– cat -n scr1

tic command
– Display a text file’s contents in reverse order
– Main purpose to display log files

43
Q

The head and tail commands

A

head command
– Displays the first 10 lines of a text file
– head scr8
– Can display more than 10 lines: head 15 scr8

tail command
– Displays the last 10 lines of a text file
– tail scr8
– Can display more than 10 lines tail 15 scr8
+ operator
* Start displaying text at a specified line number all the way to the end of the file

44
Q

The more and less commands

A

more command
– Displays a file’s contents one screen at a time

  • less command
    – Displays a file’s contents one screen at a time
    – Allows you to navigate the file by using arrow keys or the mouse wheel

Spacebar Displays next bar
#+spacebar Display the next # lines
Enter Displays next line
q Exits the more command
= Displays current line number
h Displays help

45
Q

Summary

A

Several directories should be backed up regularly particularly user’s home directories
Linux includes backup utilities tar and cpio
Archives stored on many Stored on many different types of media, such as tapes, CD RWs/DVD RWs, removable media, and hard disks