Presentation is loading. Please wait.

Presentation is loading. Please wait.

11 INFO 321 Server Technologies II Backup Applications.

Similar presentations


Presentation on theme: "11 INFO 321 Server Technologies II Backup Applications."— Presentation transcript:

1 11 INFO 321 Server Technologies II Backup Applications

2 2 System Backup ◊A key responsibility of IT professionals is to back up and restore the servers and/or network ◊We’ve examined the hardware and processes used to do so; now we’ll focus on the application or software side

3 3 System Backup ◊In Unix/Linux systems, the ‘tar’ command is a commonly used archiving mechanism ‘dump’ and ‘restore’ are also used frequently ◊‘cron’ and variations on it are used to schedule backups cron is named for Cronus, the Greek god of timeGreek god of time

4 4 Some guidance on backups ◊DO THEM! Hardware fails, often when least convenient ◊Backup from one machine to one device This centralizes scripting management ◊Label your media No, you won’t remember which one is which ◊Pick a reasonable backup time interval It’s a tradeoff between effort and risk Mostly from (Nemeth, 2007)

5 5 Some guidance on backups ◊Choose file system structure carefully Make data that changes often easier to backup If a few stray files need frequent backup, copy them to a directory that needed backup ◊Daily backups should fit on one medium Makes life easier ◊Make file systems smaller than one medium

6 6 Some guidance on backups ◊Keep media off-site Disasters are more common than you think ◊Protect your backups Remember, they span file permissions Consider encryption, and physical security ◊Limit activities during backups Or yes, you can mess up the archive ◊Verify your media

7 7 Some guidance on backups ◊Develop a media life cycle And destroy media when dead ◊Design data for backups Consider what kinds of data you have, how quickly it changes, how often you’ll back it up, who owns the data ◊Prepare for the worst Disaster planning isn’t just for FEMA

8 8 Tar ◊The ‘tar’ command is short for ‘tape archive’ Its use is analogous to WinZip, in that it also can provide compressionWinZip ◊In addition to backups, tar is also used for distributing applications A file ending in ‘.tar’ is sometimes called a tarball, but ‘archive’ is more polite Most of this section is from (Sarwar, 2002)

9 9 Tar Archives ◊A collection of files and/or directories is considered an ‘archive’ ◊Like most Unix/Linux commands, how tar works depends on the options selected The c or r options are used to create a tarball ‘c’ creates a new archive ‘r’ appends files onto an existing archive

10 10 Tar options ◊Two other commonly used options are ‘v’ is verbose mode, to tell what it’s doing ‘f’ file sets the name of the archive to file; without it, the default is the tape device /dev/rmt0 (if you have such a device!) ◊So to create a new archive called mine.tar from the current directory down would be tar cvf mine.tar.

11 11 Tar ◊The ‘.tar’ suffix is optional – it just helps Windows figure out what the file is ◊The options can have a dash before the first option; that’s more Unix-like ◊So the same command could also be tar -cvf mine.tar.

12 12 Tape devices ◊If you’re actually using a tape device, it needs to be mounted before use mount /dev/rmt0 ◊After using the device, release it with umount /dev/rmt0

13 13 Restoring archives ◊To restore an archive, use the ‘x’ option Copy (cp) the tar file to the directory in which you wish to unpack it Change directory (cd) to that directory tar xvf filename.tar ◊This is also the option used to unpack software which is distributed in tar form

14 14 Selective restoration ◊Sometimes you want to restore only specific files ◊Use the ‘t’ option to get an ls –l format listing of archive contents tar tvf filename.tar ◊If the listing is long, pipe it into more tar tvf filename.tar | more

15 15 Selective restoration ◊Then you can use the tar xvf command, and add the path to the file you want tar xvf filename.tar./directory/onefile.doc ◊Notice you need to specify the absolute or relative directory where the file will go

16 16 Adding compression ◊Some versions of tar can also do compression, using the ‘z’ option Use the ‘z’ option before the other options, for both creating and unpacking the archive Compressed archives typically end in ‘.gz’  tar –zcvf mybackup.gz to create archive  tar –zxvf mybackup.gz to unpack it

17 17 Appending onto an archive ◊For reasons not grammatically clear, the option to append onto an existing archive is ‘r’ ◊Need more tar? The full GNU version of tar is described herehere

18 18 Time to dump ◊Most forms of Linux can use dump and restore commands to create and restore backups ◊ dump creates a list of files modified since the last dump, and combines them into one large file This is perfect for incremental backups! File permissions and ownership are preserved Mostly from (Nemeth, 2007)

19 19 Why dump? ◊Dump is handled more consistently across Unix and Linux distributions Many flavors of Unix don’t support the full GNU tar features ◊Dump requires a ‘backup level’ from 0 to 9 Level 0 forces a full backup Level n forces backup of files changed since the last dump of a level less than n

20 20 More dump options ◊The ‘f’ option in dump identifies the target device for the dump The parameter after the ‘f’ option and its device is the name of the filesystem to be dumped dump -5u –f /dev/nst0 /work ◊Note that dump can only archive one filesystem; in the example, it’s /work

21 21 More dump options ◊The ‘u’ after the backup level (as in ‘-5u’ on the previous slide) forces dump to update a file /etc/dumpdates with the date, dump level, and filesystem name This provides data for future dumps to know the last dump of that filesystem

22 22 Remote dump ◊Dump only works on the local machine ◊You can use rdump to dump a local filesystem onto a remote device, such as a tape drive rdump -0u –f anchor:/dev/nst0 /spare

23 23 Dump scheduling ◊The levels in dump are strictly relative, but you can assign them to different types of backups ◊A simple schedule could use level 0 full backups every day, and keep every Nth tape permanently

24 24 Dump scheduling ◊A more complex GFS-like schedule may be A level 9 dump daily A level 5 dump weekly A level 3 dump monthly A level 0 dump at least quarterly ◊The numbers 9, 5, 3 are arbitrary for flexibility; you could use 3, 2, 1 instead

25 25 Restore command ◊The restore command does just that ◊Determine the media from which you are restoring ◊Use a temporary directory like /var/restore ◊The most common restore options are –i, -f, -r, and -x

26 26 Restore command ◊The restore –i option allows interactive marking of individual files to be restored Navigate through the archive using ls, cd, and pwd commands Mark files to be extracted with an add command When done, use extract to restore those files

27 27 Restore command ◊Like most backup commands, the –f option allows selection of the device to be restored ◊So we might open an archive with restore –i –f /dev/nst0 ◊Then add a file with add iamlost ◊And restore with extract

28 28 Remote restore ◊Matching rdump, there is an rrestore command to restore off a remote tape device ◊The –x option allows specification of a file location to be restored ◊In a remote example we might have rrestore –x –f tapehost:/dev/nst0./janet/iamlost

29 29 Restore a filesystem ◊The ‘-r’ option restores an entire file system ◊Make sure the target filesystem is properly created and mounted, and cd to the root of the filesystem ◊Load the most recent level 0 tape and use restore -r

30 30 Restore a filesystem ◊Then restore, in order, the incremental restores since that level 0 ◊In any backup level, you only need to restore the most recent one So if you have four level 5 dumps, only restore the last one

31 31 Many filesystems on one tape ◊It’s possible to dump many filesystems on one medium, space permitting Just use the dump command several times, and don’t rewind the tape in between them ◊The mt command should be used to skip forward to the correct dump on that tape, when it’s time to restore

32 32 Other backup applications ◊There are lots of other open source and proprietary backup applications Bacula Tivoli Storage Manager Veritas (now owned by Symantec)Veritas

33 33 Timed scripting ◊Ok great, we have a couple ways to create archives via command line ◊Now automate the process with timed scripts, often known as ‘cron jobs’ ◊The cron system in Linux and Unix allows apps or scripts to be run at specified times ◊It is managed via the crontab file From (Hill, 2007) and (Nemeth, 2007)

34 34 Crontab ◊Each user has a crontab file, typically under /var/spool/cron, plus a sys admin one under /etc/crontab ◊If you don’t have one yet, create one with crontab –e ◊Each line in the crontab file has five numbers, followed by the command it’s to run

35 35 Crontab ◊The numbers are, in order: Minutes (00 to 59) Hours (00 to 23, 00=midnight) Day of the month (1-31) Month of the year (1-12, 1=January) Weekday (0-6, 0=Sunday) ◊So 01 04 3 1 2 runs at 04:01 am on January 3 rd OR if it’s a Tuesday

36 36 Crontab ◊Ok, so that’s a little restrictive ◊You can enter a * to indicate any value 01 04 * * * means 04:01 am on every day of every month ◊And you can use ranges (1-15) or comma separated specific values (01,31) 01,31 04 1-15 6 means run at 04:01 and 04:31 on the 1 st through 15 th days of June

37 37 Crontab ◊So if you create a backupscript to run at 3:19 am every Saturday, the full crontab line would look like 19 03 * * 6 /usr/bin/backupscript ◊What happens if the first field is a *?

38 38 Crontab ◊You can execute multiple commands by putting them in parentheses, separated by semicolons 30 2 * * 1 (cd /users/joe/project; make) This will run /users/joe/project/make at 2:30 am every Monday

39 39 Crontab uses ◊So in addition to performing backups, crontab entries are handy for many purposes Cleaning up file systems Distributing configuration files across the network Rotating full log files ◊A newer app called anacron does interval- based scheduling, but is run from cron

40 40 Sources ◊Sarwar, Koretsky, Sarwar. Linux: The Textbook. (2002) Addison Wesley, ISBN 0201725959 ◊Nemeth, Snyder, Hein. Linux Administration Handbook. (2007) Prentice Hall, ISBN 0131480049 ◊Hill, et al. The Official Ubuntu Book. (2007) Prentice Hall, ISBN 0132354136


Download ppt "11 INFO 321 Server Technologies II Backup Applications."

Similar presentations


Ads by Google