1 / 72

CIS 191 – Lesson 11

CIS 191 – Lesson 11. Lesson Module Status Slides – draft Properties - done Flashcards - 1 st minute quiz – done Web Calendar summary – done Web book pages – Commands – done Howtos – na Skills pacing - done Lab – done Depot – NA VMs - NA. CIS 191 - Lesson 11. Quiz.

Télécharger la présentation

CIS 191 – Lesson 11

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CIS 191 – Lesson 11 • Lesson Module Status • Slides – draft • Properties - done • Flashcards - • 1st minute quiz – done • Web Calendar summary – done • Web book pages – • Commands – done • Howtos – na • Skills pacing - done • Lab – done • Depot – NA • VMs - NA

  2. CIS 191 - Lesson 11 Quiz • Please take out a blank piece of paper, switch off your monitor, close your books, put away your notes and answer these questions: • What are three ways CUPS can be configured? • What URL is used for the CUPS web based management tool? • What two commands can used to delete print jobs?

  3. CIS 191 – Lesson 11 Backup and Restore  = hands on exercise for topic

  4. CIS 191B Course Skills Pacing Lesson 8 System Admin User Mgmt Lesson 9 File System Management Holiday Lesson 12 System Monitoring Lesson 11 Backup and Restore Lesson 10 Printing Lesson 13 The kernel Review Final

  5. CIS 191 - Lesson 11 Last weeks Assignment • Questions on previous material or assignments? • mingetty -> login -> bash? • windows print share? • CUPS device URI?

  6. CIS 191 - Lesson 11 Backup and Restore

  7. CIS 191 - Lesson 11 Backup and Restore The Backup Process • Losing data • Backup Policies • Devices • Problems with Backup Programs • Restoring Data • File Permissions, Types, and Structures • Defragmentation • Protecting the Backup Media

  8. CIS 191 - Lesson 11 Backup and Restore Losing data • How to lose data • Software bugs • Pilot errors • Hardware failures • Hackers • Many more ways … It will happen!

  9. CIS 191 - Lesson 11 Backup and Restore Backup Policies • Backup Policies (from textbook 9.1) • Perform LAN backups from one system • Label the media • Choose reasonable backup interval • Factor in modification frequency of files/filesystems • Make daily dumps fit on one piece of media • Make filesystems smaller than the backup media • Keep media off-site • Secure off-site media • Limit activity during backups • Verify your media • Pay attention to media life • Design your storage with backups in mind • Prepare for the worst

  10. CIS 191 - Lesson 11 Backup and Restore Backup devices • Tape Devices • Problems with tapes • The buffer utility • Tapes and random file access • Writable CD and DVD • CDs 650MB ($.15-30 each) • DVDs 4.7 GB ($.20-43 each) • DVDs (DL) 8.5 GB ($2-4 each) • Blu-ray 25 GB ($8-12 each) • 1-5 years to 100's of years (if stored properly) • Other Removable Media Devices • USB/Firewire • Solid state, external drives • Hard drives and RAID Arrays

  11. CIS 191 - Lesson 11 Backup and Restore Types of Data • System Data • Basic information to set and run the system • Application Software • Best to reinstall from source installation disks • Databases • Most important data types • User Data • Includes site work • User Data and Home Directories • Includes e-mail, files from home directory for personal use

  12. CIS 191 - Lesson 11 Backup and Restore Methodologies • Epoch • Arbitrary time interval that denotes a beginning • Incremental • All files that have been added or changed since epoch • Differential • Similar but easier than incremental, only uses two tapes • File ghosting • Anomaly of the backup and restoration process where deleted files turn up again!

  13. CIS 191 - Lesson 11 Backup and Restore Archive Utilities • dump/restore • Oldest and most trusted backup utility • Backs up filesystems, not files (block-based and fast) • Multiple levels of incremental backups • tar • Used to archive or backup files, directories, hard disks • cpio • Copy input/output • can use output of find command for wide range of file selection critera (by type, user, modification time, etc)

  14. CIS 191 - Lesson 11 Backup and Restore Compression Utilities • compress • Traditional compression utility • Not on CentOS 5 • zip • Used for compressing, archiving files into single archive • compatible with WinZip • gzip • Used for compressing, uncompressing files one at a time • bzip2 • New, slower, but better compression device

  15. CIS 191 - Lesson 11 Backup and Restore Backup Software Packages • AMANDA - http://www.amanda.org/ • Kbackup - http://kbackup.sourceforge.net/ • UNiBack - http://www.orbitsw.co.uk/uni_index.html • Taper - http://taper.sourceforge.net/ • Arkeia - http://www.arkeia.com/ • Rsync - http://rsync.samba.org/ • Dar & KDar - http://kdar.sourceforge.net/ • Partimage (like Ghost) - http://partimage.org/Main_Page

  16. CIS 191 - Lesson 11 Backup and Restore Backup Software Packages • AMANDA • Advanced Maryland Automatic Network Disk Archiver • Able to split backups across media • No GUI, command line only • Can backup other servers over the network • Uses native dump and tar utilities • Amanda also can use SAMBA top backup Windows hosts • http://www.amanda.org/

  17. CIS 191 - Lesson 11 Backup and Restore Backup Software Packages • Kbackup • Can use PGP to encrypt • Can use gzip or compress to compress archives • full or incremental backups • access remote devices for LAN backups • http://kbackup.sourceforge.net/

  18. CIS 191 - Lesson 11 tar

  19. CIS 191 - Lesson 11 tar command options (no – needed) files to backup c tvf x archive file tarfile tar file(s) create table of contents (view) extract v = verbose, double v (vv) provides more information Note: The full path to each file is stored in the archive and these paths are used when restoring files

  20. CIS 191 - Lesson 11 tar command Single file example [root@benji ~]# cd /opt/lampp/htdocs/ [root@benjihtdocs]# ls -l sample.html -rw-r--r-- 1 root root 194 Oct 24 10:13 sample.html [root@benjihtdocs]# cat sample.html <html> <head> <title>My first page</title> </head> <body> <h1>My first web page</h1> <p>Nothing can stop me now</p> <a href="http://google.com">My link to Google</a> </body> </html> [root@benjihtdocs]# [root@benjihtdocs]# tar cvf /root/sample.tar sample.html sample.html [root@benjihtdocs]# ls -l /root/sample.tar -rw-r--r-- 1 root root 10240 Nov 22 08:56 /root/sample.tar [root@benjihtdocs]# rm sample.html rm: remove regular file `sample.html'? y [root@benjihtdocs]# tar tvf /root/sample.tar -rw-r--r-- root/root 194 2008-10-24 10:13:10 sample.html [root@benjihtdocs]# tar xvf /root/sample.tar sample.html sample.html [root@benjihtdocs]# ls -l sample.html -rw-r--r-- 1 root root 194 Oct 24 10:13 sample.html [root@benjihtdocs]# cat sample.html <html> <head> <title>My first page</title> </head> <body> <h1>My first web page</h1> <p>Nothing can stop me now</p> <a href="http://google.com">My link to Google</a> </body> </html> [root@benjihtdocs]# Backup a web page file Oops! – file gets deleted View backed up file Restore the file

  21. CIS 191 - Lesson 11 tar command Single file example verbose file to back up (requires full path) tarfile to use create • tar cvf /root/sample.tar sample.html • sample.html • tar tvf /root/sample.tar • -rw-r--r-- root/root 194 2008-10-24 10:13:10 sample.html • tar xvf /root/sample.tar sample.html • sample.html verbose tarfile to use view (table of contents) verbose file in archive to restore (requires full path) tarfile to use extract

  22. CIS 191 - Lesson 11 tar command Pay attention to the path stored in the tarfile Creating the tarfile from another directory using absolute path [root@benji ~]# tar cvf sample2.tar /opt/lampp/htdocs/sample.html tar: Removing leading `/' from member names /opt/lampp/htdocs/sample.html [root@benji ~]# tar tvf sample2.tar -rw-r--r-- root/root 194 2008-10-24 10:13:10 opt/lampp/htdocs/sample.html [root@benji ~]# [root@benji ~]# tar cvf sample2.tar ../opt/lampp/htdocs/sample.html tar: Removing leading `../' from member names ../opt/lampp/htdocs/sample.html [root@benji ~]# tar tvf sample2.tar -rw-r--r-- root/root 194 2008-10-24 10:13:10 opt/lampp/htdocs/sample.html [root@benji ~]# Note, the leading / gets stripped This path is used when restoring files Creating the tarfile from another directory using relative path path Note, the leading ../ gets stripped This path is used when restoring files

  23. CIS 191 - Lesson 11 tar command -C option -C dir -xvf tar tarfile files(s) The –C option can be used to set the starting directory for file to be restored to. Add a – to the other options as well

  24. CIS 191 - Lesson 11 tar command -C option Find file to restore in archive [root@benji ~]# tar tf htdocs.tar | grep jp.php ./xampp/lang/jp.php [root@benjilang]# cd /opt/lampp/htdocs/ [root@benjihtdocs]# tar xvf /root/htdocs.tar ./xampp/lang/jp.php ./xampp/lang/jp.php [root@benjihtdocs]# [root@benji~]# tar -C /opt/lampp/htdocs/ -xvf htdocs.tar ./xampp/lang/jp.php ./xampp/lang/jp.php [root@benji ~]# Change to the directory where the backup was made Or use the –C option to restore from another directory

  25. CIS 191 - Lesson 11 Class Exercise tar command • Change to the /opt/lampp/htdocs directory. • Backup sample.html using: • tar cvf /root/sample.tar sample.html • Verify your tarfile contains sample.html • What is the path to sample.html in the tarfile? [Table 1-4] • Delete then practice restoring sample.html: • To its original location • Where did you have to be to do this? [Table 9-12] • To the /tmpdirectory • Where did you have to be to do this? [Table 17-20] • Now use the tar man page to check out the –C directory option. • Delete the sample.html in the /tmpdirectory • Restore sample.html from /root to the /tmpdirectory with the –C option. What command did you use [Table 5-9]?

  26. CIS 191 - Lesson 11 tar command Directory example [root@benjihtdocs]# tar cvf /root/htdocs.tar . ./ ./webalizer/ ./sample.html ./xampp/ ./xampp/lang.tmp ./xampp/xampp.js ./xampp/index.php ./xampp/test/ ./xampp/test/xampp_ming/ ./xampp/test/xampp_ming/gif.gif ./xampp/test/xampp_ming/jpg.jpg ./xampp/test/xampp_ming/png.png ./xampp/test/xampp_ming/bitmaps.php ./xampp/test/xampp_win.png ./xampp/test/xampp_ming.zip ./xampp/perl.pl ./xampp/guestbook-no.pl ./xampp/splash-swf.php ./xampp/guestbook-pl.pl ./xampp/ssi.shtml ./xampp/components.php ./xampp/contrib/ ./xampp/contrib/oracle.php ./xampp/contrib/cds.xml ./xampp/contrib/soap.php ./xampp/contrib/sqlite.php ./xampp/contrib/sax.php ./xampp/contrib/postgresql.pl ./xampp/contrib/interbase.pl ./xampp/contrib/mysql.php ./xampp/contrib/dom.php ./xampp/contrib/mingstats_swf.php ./xampp/contrib/mysql.pl ./xampp/contrib/testperldbi.pl ./xampp/contrib/xmlrss.php ./xampp/contrib/mingstats.html ./xampp/contrib/sql2xml.php ./xampp/contrib/sqlite.pl ./xampp/contrib/BabelSans-B.fdb ./xampp/contrib/oracle.pl ./xampp/contrib/interbase.php ./xampp/contrib/postgresql.php ./xampp/manuals.php ./xampp/cgi.cgi ./xampp/cds.php ./xampp/webalizer.php ./xampp/biorhythm.php ./xampp/AnkeCalligraph.TTF ./xampp/head.php ./xampp/guestbook-zh.pl ./xampp/start.php ./xampp/AnkeCalligraph.fdb ./xampp/mingswf.php ./xampp/mysql.php ./xampp/guestbook-nl.pl ./xampp/navi.php ./xampp/lang.php ./xampp/security.php ./xampp/lang/ ./xampp/lang/de.php ./xampp/lang/it.php ./xampp/lang/fr.php ./xampp/lang/es.php ./xampp/lang/pt_br.php ./xampp/lang/nl.php ./xampp/lang/zh.php ./xampp/lang/no.php ./xampp/lang/pl.php ./xampp/lang/en.php ./xampp/lang/languages.php ./xampp/lang/jp.php ./xampp/splash-logo.php ./xampp/langsettings.php ./xampp/.version ./xampp/status.php ./xampp/phonebook.php ./xampp/img/ ./xampp/img/rb.gif ./xampp/img/status3.gif ./xampp/img/logo-small.gif ./xampp/img/logo-small.jpg ./xampp/img/new.png ./xampp/img/signature-kay.gif ./xampp/img/lt.gif ./xampp/img/benji-500x420.jpg ./xampp/img/status4.gif ./xampp/img/rt.gif ./xampp/img/strichel.gif ./xampp/img/head-linux.gif ./xampp/img/head-xampp.gif ./xampp/img/xampp-logo.jpg ./xampp/img/head-fuer.gif ./xampp/img/head-for.gif ./xampp/img/head-solaris.gif ./xampp/img/status2.gif ./xampp/img/status1.gif ./xampp/img/head-windows.gif ./xampp/img/logo-big.gif ./xampp/img/signature-oswald.gif ./xampp/img/status5.gif ./xampp/img/blank.gif ./xampp/img/lb.gif ./xampp/img/xampp-logo-new.gif ./xampp/img/apachefriends.gif ./xampp/guestbook-es.pl ./xampp/guestbook-de.pl ./xampp/phpinfo.php ./xampp/splash.php ./xampp/guestbook-pt_br.pl ./xampp/guestbook.dat ./xampp/charset.php ./xampp/test.php ./xampp/softwarelist.inc ./xampp/guestbook-it.pl ./xampp/cds-fpdf.php ./xampp/ssi.inc ./xampp/php.php ./xampp/sqlite/ ./xampp/sqlite/cdcol ./xampp/sqlite/phonebook.sqlite ./xampp/sqlite/.htaccess ./xampp/xampp.css ./xampp/ming.php ./xampp/showcode.php ./xampp/guestbook-fr.pl ./xampp/guestbook-en.pl ./xampp/iart.php ./.hidden ./favicon.ico ./index.html [root@benjihtdocs]# rmxampp/iart.php .hidden sample.html rm: remove regular file `xampp/iart.php'? y rm: remove regular empty file `.hidden'? y rm: remove regular file `sample.html'? y [root@benjihtdocs]# tar tvf /root/htdocs.tar ./xampp/iart.php ./.hidden ./sample.html -rw-r--r-- root/root 194 2008-10-24 10:13:10 ./sample.html -rw-r--r-- root/root 3004 2006-11-10 08:57:01 ./xampp/iart.php -rw-r--r-- root/root 0 2008-11-22 09:23:17 ./.hidden [root@benjihtdocs]# tar xvf /root/htdocs.tar ./xampp/iart.php ./.hidden ./sample.html ./sample.html ./xampp/iart.php ./.hidden Backup up files (including hidden and sub-directories) starting from "here" Note how tar saves full path for each file backed up Delete some files Verify they were backed up Restore the files that were deleted

  27. CIS 191 - Lesson 11 tarfile to use tar command Directory example create files to back up (starting point) verbose tar cvf /root/htdocs.tar . ./ ./webalizer/ ./sample.html ./xampp/ ./xampp/lang.tmp ./xampp/xampp.js ./xampp/index.php ./xampp/test/ ./xampp/test/xampp_ming/ ./xampp/test/xampp_ming/gif.gif ./xampp/test/xampp_ming/jpg.jpg ./xampp/test/xampp_ming/png.png ./xampp/test/xampp_ming/bitmaps.php ./xampp/test/xampp_win.png ./xampp/test/xampp_ming.zip ./xampp/perl.pl ./xampp/guestbook-no.pl ./xampp/splash-swf.php ./xampp/guestbook-pl.pl ./xampp/ssi.shtml ./xampp/components.php ./xampp/contrib/ ./xampp/contrib/oracle.php ./xampp/contrib/cds.xml ./xampp/contrib/soap.php ./xampp/contrib/sqlite.php ./xampp/contrib/sax.php ./xampp/contrib/postgresql.pl ./xampp/contrib/interbase.pl ./xampp/contrib/mysql.php ./xampp/contrib/dom.php ./xampp/contrib/mingstats_swf.php ./xampp/contrib/mysql.pl ./xampp/contrib/testperldbi.pl ./xampp/guestbook-es.pl ./xampp/guestbook-de.pl ./xampp/phpinfo.php ./xampp/splash.php ./xampp/guestbook-pt_br.pl ./xampp/guestbook.dat ./xampp/charset.php ./xampp/test.php ./xampp/softwarelist.inc ./xampp/guestbook-it.pl ./xampp/cds-fpdf.php ./xampp/ssi.inc ./xampp/php.php ./xampp/sqlite/ ./xampp/sqlite/cdcol ./xampp/sqlite/phonebook.sqlite ./xampp/sqlite/.htaccess ./xampp/xampp.css ./xampp/ming.php ./xampp/showcode.php ./xampp/guestbook-fr.pl ./xampp/guestbook-en.pl ./xampp/iart.php ./.hidden ./favicon.ico ./index.html ./xampp/contrib/xmlrss.php ./xampp/contrib/mingstats.html ./xampp/contrib/sql2xml.php ./xampp/contrib/sqlite.pl ./xampp/contrib/BabelSans-B.fdb ./xampp/contrib/oracle.pl ./xampp/contrib/interbase.php ./xampp/contrib/postgresql.php ./xampp/manuals.php ./xampp/cgi.cgi ./xampp/cds.php ./xampp/webalizer.php ./xampp/biorhythm.php ./xampp/AnkeCalligraph.TTF ./xampp/head.php ./xampp/guestbook-zh.pl ./xampp/start.php ./xampp/AnkeCalligraph.fdb ./xampp/mingswf.php ./xampp/mysql.php ./xampp/guestbook-nl.pl ./xampp/navi.php ./xampp/lang.php ./xampp/security.php ./xampp/lang/ ./xampp/lang/de.php ./xampp/lang/it.php ./xampp/lang/fr.php ./xampp/lang/es.php ./xampp/lang/pt_br.php ./xampp/lang/nl.php ./xampp/lang/zh.php ./xampp/lang/no.php ./xampp/lang/pl.php ./xampp/lang/languages.php ./xampp/lang/jp.php ./xampp/splash-logo.php ./xampp/langsettings.php ./xampp/.version ./xampp/status.php ./xampp/phonebook.php ./xampp/img/ ./xampp/img/rb.gif ./xampp/img/status3.gif ./xampp/img/logo-small.gif ./xampp/img/logo-small.jpg ./xampp/img/new.png ./xampp/img/signature-kay.gif ./xampp/img/lt.gif ./xampp/img/benji-500x420.jpg ./xampp/img/status4.gif ./xampp/img/rt.gif ./xampp/img/strichel.gif ./xampp/img/head-linux.gif ./xampp/img/head-xampp.gif ./xampp/img/xampp-logo.jpg ./xampp/img/head-fuer.gif ./xampp/img/head-for.gif ./xampp/img/head-solaris.gif ./xampp/img/status2.gif ./xampp/img/status1.gif ./xampp/img/head-windows.gif ./xampp/img/logo-big.gif ./xampp/img/signature-oswald.gif ./xampp/img/status5.gif ./xampp/img/blank.gif ./xampp/img/lb.gif ./xampp/img/xampp-logo-new.gif

  28. CIS 191 - Lesson 11 tar command Directory example view (table of contents) verbose tarfile Files to find in archive [root@benjihtdocs]# tar tvf /root/htdocs.tar ./xampp/iart.php ./.hidden ./sample.html -rw-r--r-- root/root 194 2008-10-24 10:13:10 ./sample.html -rw-r--r-- root/root 3004 2006-11-10 08:57:01 ./xampp/iart.php -rw-r--r-- root/root 0 2008-11-22 09:23:17 ./.hidden [root@benjihtdocs]# tar xvf /root/htdocs.tar ./xampp/iart.php ./.hidden ./sample.html ./sample.html ./xampp/iart.php ./.hidden verbose extract tarfile Files to find to extract

  29. CIS 191 - Lesson 11 Class Exercise tar command • Change to the /opt/lampp/ directory. Note the htdocs and backup directories. • Backup the htdocs directory (including sub-directories) to htdocs-20081125.tar the backup directory. What command did you use? [Table 21-24] • Verify your tarfile contains xampp/lang/jp.phpWhat command did you use? From where? [Table 1-4] • Delete and then restore xampp/lang/jp.php from the backup directory What command did you use? [Table 9-12]

  30. CIS 191 - Lesson 11 tar command Size can differ between tarfile and backed up file • Tarfiles • Tarfile can be smaller than backed up file as it only saves the date, not unused portion of data blocks • Tarfile can be larger if backed up file is a sparse file • Additional empty blocks can be added to tar version

  31. CIS 191 - Lesson 11 tar command du size can differ between tarfile and backed up file • Tarfiles • Additional empty blocks can be added to tar version [root@benji log]# cp messages /root; tar cvf /root/messages.tar messages; tar -cSvf /root/messagesS.tar messages [root@benji ~]# ls -l messages /var/log/messages sparse/messages nosparse/messages -rw------- 1 root root127538 Nov 22 08:20 messages -rw------- 1 root root127538 Nov 22 08:13 nosparse/messages -rw------- 1 root root127538 Nov 22 08:13 sparse/messages -rw------- 1 root root127538 Nov 22 08:13 /var/log/messages [root@benji ~]# [root@benji ~]# du messages /var/log/messages sparse/messages nosparse/messages 136 messages 127 /var/log/messages 136 sparse/messages 136nosparse/messages ls command show same size for original, copy and tar extracts original file original file du report shows more disk space used than original for copy and tar extracts Note: the –s option is to handle sparse files (discussed later)

  32. CIS 191 - Lesson 11 tar command Size can differ between tarfile and backed up file • Tarfiles • Additional empty blocks can be added to tar version [root@benji ~]# stat messages /var/log/messages sparse/messages nosparse/messages File: `messages' Size: 127538 Blocks: 272 IO Block: 4096 regular file <snipped> File: `/var/log/messages' Size: 127538 Blocks: 254 IO Block: 4096 regular file <snipped> File: `sparse/messages' Size: 127538 Blocks: 272 IO Block: 4096 regular file <snipped> File: `nosparse/messages' Size: 127538 Blocks: 272 IO Block: 4096 regular file <snipped> [root@benji ~]# stat command shows copy and files extracted from tarfile have additional blocks which explains why file size is the same but disk usage is higher.

  33. CIS 191 - Lesson 11 tar command sparse files • Sparse Files • Null blocks (containing only zeroes) are not stored on the disk • Can be problematic if utilities don't recognize them [root@benji ~]# cd /var/log [root@benji log]# ls -l lastlog -rw-r--r-- 1 root root 234476 Nov 22 05:18 lastlog [root@benji log]# du -h lastlog 16K lastlog Note the reduced size of the file actually stored on the disk using du –h command

  34. CIS 191 - Lesson 11 tar command sparse files • Sparse Files • tar command without using the sparse option (-S) for sparse file [root@benji ~]# cd /var/log [root@benji log]# tar cvf /root/lastlog.tar lastlog lastlog [root@benji log]# cd /root [root@benji ~]# ls -l lastlog.tar -rw-r--r-- 1 root root 245760 Nov 22 05:19 lastlog.tar [root@benji ~]# du -h lastlog.tar 248K lastlog.tar [root@benji ~]# tar xvf lastlog.tar lastlog [root@benji ~]# ls -l lastlog -rw-r--r-- 1 root root 234476 Nov 22 05:18 lastlog [root@benji ~]# du -h lastlog 240K lastlog The tarfile has expanded all the null blocks increasing disk space usage

  35. CIS 191 - Lesson 11 tar command sparse files • Sparse Files • tar command using the sparse option (-S) with sparse file [root@benji ~]# cd /var/log [root@benji log]# tar cSvf /root/lastlog2.tar lastlog lastlog [root@benji log]# cd /root [root@benji ~]# tar xvf lastlog2.tar lastlog [root@benji ~]# ls -l lastlog -rw-r--r-- 1 root root 234476 Nov 22 05:18 lastlog [root@benji ~]# du -h lastlog 20K lastlog [root@benji ~]# Using the -S option, the tar command handles the sparse file efficiently

  36. CIS 191 - Lesson 11 tar command compression c t vf x z j tarfile tar file(s) -C dir The z option uses gzip compresssion and the j option uses bzip2 compression bzip2 is slower, but compresses more gzip is faster, but compreses less

  37. CIS 191 - Lesson 11 tar command compression [root@benjihtdocs]# tar cvf /opt/lampp/backup/htdocs.tar . ./ ./webalizer/ ./sample.html ./xampp/ ./xampp/lang.tmp ./xampp/xampp.js ./xampp/index.php ./xampp/test/ ./xampp/test/xampp_ming/ ./xampp/test/xampp_ming/gif.gif ./xampp/test/xampp_ming/jpg.jpg ./xampp/test/xampp_ming/png.png ./xampp/test/xampp_ming/bitmaps.php ./xampp/test/xampp_win.png ./xampp/test/xampp_ming.zip ./xampp/perl.pl ./xampp/guestbook-no.pl ./xampp/splash-swf.php ./xampp/guestbook-pl.pl ./xampp/ssi.shtml ./xampp/components.php ./xampp/contrib/ ./xampp/contrib/oracle.php ./xampp/contrib/cds.xml ./xampp/contrib/soap.php ./xampp/contrib/sqlite.php ./xampp/contrib/sax.php ./xampp/contrib/postgresql.pl ./xampp/contrib/interbase.pl ./xampp/contrib/mysql.php ./xampp/contrib/dom.php ./xampp/contrib/mingstats_swf.php ./xampp/contrib/mysql.pl ./xampp/contrib/testperldbi.pl ./xampp/contrib/xmlrss.php ./xampp/contrib/mingstats.html ./xampp/contrib/sql2xml.php ./xampp/contrib/sqlite.pl ./xampp/contrib/BabelSans-B.fdb ./xampp/contrib/oracle.pl ./xampp/contrib/interbase.php ./xampp/contrib/postgresql.php ./xampp/manuals.php ./xampp/cgi.cgi ./xampp/cds.php ./xampp/webalizer.php ./xampp/biorhythm.php ./xampp/AnkeCalligraph.TTF ./xampp/head.php ./xampp/guestbook-zh.pl ./xampp/start.php ./xampp/AnkeCalligraph.fdb ./xampp/mingswf.php ./xampp/mysql.php ./xampp/guestbook-nl.pl ./xampp/navi.php ./xampp/lang.php ./xampp/security.php ./xampp/lang/ ./xampp/lang/de.php ./xampp/lang/it.php ./xampp/lang/fr.php ./xampp/lang/es.php ./xampp/lang/pt_br.php ./xampp/lang/nl.php ./xampp/lang/zh.php ./xampp/lang/no.php ./xampp/lang/pl.php ./xampp/lang/en.php ./xampp/lang/languages.php ./xampp/lang/jp.php ./xampp/splash-logo.php ./xampp/langsettings.php ./xampp/.version ./xampp/status.php ./xampp/phonebook.php ./xampp/img/ ./xampp/img/rb.gif ./xampp/img/status3.gif ./xampp/img/logo-small.gif ./xampp/img/logo-small.jpg ./xampp/img/new.png ./xampp/img/signature-kay.gif ./xampp/img/lt.gif ./xampp/img/benji-500x420.jpg ./xampp/img/status4.gif ./xampp/img/rt.gif ./xampp/img/strichel.gif ./xampp/img/head-linux.gif ./xampp/img/head-xampp.gif ./xampp/img/xampp-logo.jpg ./xampp/img/head-fuer.gif ./xampp/img/head-for.gif ./xampp/img/head-solaris.gif ./xampp/img/status2.gif ./xampp/img/status1.gif ./xampp/img/head-windows.gif ./xampp/img/logo-big.gif ./xampp/img/signature-oswald.gif ./xampp/img/status5.gif ./xampp/img/blank.gif ./xampp/img/lb.gif ./xampp/img/xampp-logo-new.gif ./xampp/img/apachefriends.gif ./xampp/guestbook-es.pl ./xampp/guestbook-de.pl ./xampp/phpinfo.php ./xampp/splash.php ./xampp/guestbook-pt_br.pl ./xampp/guestbook.dat ./xampp/charset.php ./xampp/test.php ./xampp/softwarelist.inc ./xampp/guestbook-it.pl ./xampp/cds-fpdf.php ./xampp/ssi.inc ./xampp/php.php ./xampp/sqlite/ ./xampp/sqlite/cdcol ./xampp/sqlite/phonebook.sqlite ./xampp/sqlite/.htaccess ./xampp/xampp.css ./xampp/ming.php ./xampp/showcode.php ./xampp/guestbook-fr.pl ./xampp/guestbook-en.pl ./xampp/iart.php ./.hidden ./favicon.ico ./index.html [root@benjihtdocs]# [root@benji backup]# ls -l htdocs.tar; du -h htdocs.tar -rw-r--r-- 1 root root706560 Nov 22 13:13 htdocs.tar 695K htdocs.tar [root@benji backup]# Backing up htdocs with no compression

  38. CIS 191 - Lesson 11 tar command compression [root@benjihtdocs]# tar cvf /opt/lampp/backup/htdocs2.tar . ./ ./webalizer/ ./sample.html ./xampp/ ./xampp/lang.tmp ./xampp/xampp.js ./xampp/index.php ./xampp/test/ ./xampp/test/xampp_ming/ ./xampp/test/xampp_ming/gif.gif ./xampp/test/xampp_ming/jpg.jpg ./xampp/test/xampp_ming/png.png ./xampp/test/xampp_ming/bitmaps.php ./xampp/test/xampp_win.png ./xampp/test/xampp_ming.zip ./xampp/perl.pl ./xampp/guestbook-no.pl ./xampp/splash-swf.php ./xampp/guestbook-pl.pl ./xampp/ssi.shtml ./xampp/components.php ./xampp/contrib/ ./xampp/contrib/oracle.php ./xampp/contrib/cds.xml ./xampp/contrib/soap.php ./xampp/contrib/sqlite.php ./xampp/contrib/sax.php ./xampp/contrib/postgresql.pl ./xampp/contrib/interbase.pl ./xampp/contrib/mysql.php ./xampp/contrib/dom.php ./xampp/contrib/mingstats_swf.php ./xampp/contrib/mysql.pl ./xampp/contrib/testperldbi.pl ./xampp/contrib/xmlrss.php ./xampp/contrib/mingstats.html ./xampp/contrib/sql2xml.php ./xampp/contrib/sqlite.pl ./xampp/contrib/BabelSans-B.fdb ./xampp/contrib/oracle.pl ./xampp/contrib/interbase.php ./xampp/contrib/postgresql.php ./xampp/manuals.php ./xampp/cgi.cgi ./xampp/cds.php ./xampp/webalizer.php ./xampp/biorhythm.php ./xampp/AnkeCalligraph.TTF ./xampp/head.php ./xampp/guestbook-zh.pl ./xampp/start.php ./xampp/AnkeCalligraph.fdb ./xampp/mingswf.php ./xampp/mysql.php ./xampp/guestbook-nl.pl ./xampp/navi.php ./xampp/lang.php ./xampp/security.php ./xampp/lang/ ./xampp/lang/de.php ./xampp/lang/it.php ./xampp/lang/fr.php ./xampp/lang/es.php ./xampp/lang/pt_br.php ./xampp/lang/nl.php ./xampp/lang/zh.php ./xampp/lang/no.php ./xampp/lang/pl.php ./xampp/lang/en.php ./xampp/lang/languages.php ./xampp/lang/jp.php ./xampp/splash-logo.php ./xampp/langsettings.php ./xampp/.version ./xampp/status.php ./xampp/phonebook.php ./xampp/img/ ./xampp/img/rb.gif ./xampp/img/status3.gif ./xampp/img/logo-small.gif ./xampp/img/logo-small.jpg ./xampp/img/new.png ./xampp/img/signature-kay.gif ./xampp/img/lt.gif ./xampp/img/benji-500x420.jpg ./xampp/img/status4.gif ./xampp/img/rt.gif ./xampp/img/strichel.gif ./xampp/img/head-linux.gif ./xampp/img/head-xampp.gif ./xampp/img/xampp-logo.jpg ./xampp/img/head-fuer.gif ./xampp/img/head-for.gif ./xampp/img/head-solaris.gif ./xampp/img/status2.gif ./xampp/img/status1.gif ./xampp/img/head-windows.gif ./xampp/img/logo-big.gif ./xampp/img/signature-oswald.gif ./xampp/img/status5.gif ./xampp/img/blank.gif ./xampp/img/lb.gif ./xampp/img/xampp-logo-new.gif ./xampp/img/apachefriends.gif ./xampp/guestbook-es.pl ./xampp/guestbook-de.pl ./xampp/phpinfo.php ./xampp/splash.php ./xampp/guestbook-pt_br.pl ./xampp/guestbook.dat ./xampp/charset.php ./xampp/test.php ./xampp/softwarelist.inc ./xampp/guestbook-it.pl ./xampp/cds-fpdf.php ./xampp/ssi.inc ./xampp/php.php ./xampp/sqlite/ ./xampp/sqlite/cdcol ./xampp/sqlite/phonebook.sqlite ./xampp/sqlite/.htaccess ./xampp/xampp.css ./xampp/ming.php ./xampp/showcode.php ./xampp/guestbook-fr.pl ./xampp/guestbook-en.pl ./xampp/iart.php ./.hidden ./favicon.ico ./index.html [root@benjihtdocs]# gzip ../backup/htdocs2.tar [root@benji backup]# ls -l htdocs2.tar.gz; du -h htdocs2.tar.gz -rw-r--r-- 1 root root343760 Nov 22 13:15 htdocs2.tar.gz 340K htdocs2.tar.gz [root@benji backup]# Post-compression using gzip of archive

  39. CIS 191 - Lesson 11 tar command compression [root@benjihtdocs]# tar cvf /opt/lampp/backup/htdocs2.tar . ./ ./webalizer/ ./sample.html ./xampp/ ./xampp/lang.tmp ./xampp/xampp.js ./xampp/index.php ./xampp/test/ ./xampp/test/xampp_ming/ ./xampp/test/xampp_ming/gif.gif ./xampp/test/xampp_ming/jpg.jpg ./xampp/test/xampp_ming/png.png ./xampp/test/xampp_ming/bitmaps.php ./xampp/test/xampp_win.png ./xampp/test/xampp_ming.zip ./xampp/perl.pl ./xampp/guestbook-no.pl ./xampp/splash-swf.php ./xampp/guestbook-pl.pl ./xampp/ssi.shtml ./xampp/components.php ./xampp/contrib/ ./xampp/contrib/oracle.php ./xampp/contrib/cds.xml ./xampp/contrib/soap.php ./xampp/contrib/sqlite.php ./xampp/contrib/sax.php ./xampp/contrib/postgresql.pl ./xampp/contrib/interbase.pl ./xampp/contrib/mysql.php ./xampp/contrib/dom.php ./xampp/contrib/mingstats_swf.php ./xampp/contrib/mysql.pl ./xampp/contrib/testperldbi.pl ./xampp/contrib/xmlrss.php ./xampp/contrib/mingstats.html ./xampp/contrib/sql2xml.php ./xampp/contrib/sqlite.pl ./xampp/contrib/BabelSans-B.fdb ./xampp/contrib/oracle.pl ./xampp/contrib/interbase.php ./xampp/contrib/postgresql.php ./xampp/manuals.php ./xampp/cgi.cgi ./xampp/cds.php ./xampp/webalizer.php ./xampp/biorhythm.php ./xampp/AnkeCalligraph.TTF ./xampp/head.php ./xampp/guestbook-zh.pl ./xampp/start.php ./xampp/AnkeCalligraph.fdb ./xampp/mingswf.php ./xampp/mysql.php ./xampp/guestbook-nl.pl ./xampp/navi.php ./xampp/lang.php ./xampp/security.php ./xampp/lang/ ./xampp/lang/de.php ./xampp/lang/it.php ./xampp/lang/fr.php ./xampp/lang/es.php ./xampp/lang/pt_br.php ./xampp/lang/nl.php ./xampp/lang/zh.php ./xampp/lang/no.php ./xampp/lang/pl.php ./xampp/lang/en.php ./xampp/lang/languages.php ./xampp/lang/jp.php ./xampp/splash-logo.php ./xampp/langsettings.php ./xampp/.version ./xampp/status.php ./xampp/phonebook.php ./xampp/img/ ./xampp/img/rb.gif ./xampp/img/status3.gif ./xampp/img/logo-small.gif ./xampp/img/logo-small.jpg ./xampp/img/new.png ./xampp/img/signature-kay.gif ./xampp/img/lt.gif ./xampp/img/benji-500x420.jpg ./xampp/img/status4.gif ./xampp/img/rt.gif ./xampp/img/strichel.gif ./xampp/img/head-linux.gif ./xampp/img/head-xampp.gif ./xampp/img/xampp-logo.jpg ./xampp/img/head-fuer.gif ./xampp/img/head-for.gif ./xampp/img/head-solaris.gif ./xampp/img/status2.gif ./xampp/img/status1.gif ./xampp/img/head-windows.gif ./xampp/img/logo-big.gif ./xampp/img/signature-oswald.gif ./xampp/img/status5.gif ./xampp/img/blank.gif ./xampp/img/lb.gif ./xampp/img/xampp-logo-new.gif ./xampp/img/apachefriends.gif ./xampp/guestbook-es.pl ./xampp/guestbook-de.pl ./xampp/phpinfo.php ./xampp/splash.php ./xampp/guestbook-pt_br.pl ./xampp/guestbook.dat ./xampp/charset.php ./xampp/test.php ./xampp/softwarelist.inc ./xampp/guestbook-it.pl ./xampp/cds-fpdf.php ./xampp/ssi.inc ./xampp/php.php ./xampp/sqlite/ ./xampp/sqlite/cdcol ./xampp/sqlite/phonebook.sqlite ./xampp/sqlite/.htaccess ./xampp/xampp.css ./xampp/ming.php ./xampp/showcode.php ./xampp/guestbook-fr.pl ./xampp/guestbook-en.pl ./xampp/iart.php ./.hidden ./favicon.ico ./index.html [root@benjihtdocs]# bzip2 ../backup/htdocs2.tar [root@benji backup]# ls -l htdocs2.tar.bz2; du -h htdocs2.tar.bz2 -rw-r--r-- 1 root root340646 Nov 22 13:18 htdocs2.tar.bz2 337K htdocs2.tar.bz2 [root@benji backup]# Post-compression using bzip2 of archive

  40. CIS 191 - Lesson 11 tar command compression [root@benjihtdocs]# tar czvf /opt/lampp/backup/htdocs.tar.gz . ./ ./webalizer/ ./sample.html ./xampp/ ./xampp/lang.tmp ./xampp/xampp.js ./xampp/index.php ./xampp/test/ ./xampp/test/xampp_ming/ ./xampp/test/xampp_ming/gif.gif ./xampp/test/xampp_ming/jpg.jpg ./xampp/test/xampp_ming/png.png ./xampp/test/xampp_ming/bitmaps.php ./xampp/test/xampp_win.png ./xampp/test/xampp_ming.zip ./xampp/perl.pl ./xampp/guestbook-no.pl ./xampp/splash-swf.php ./xampp/guestbook-pl.pl ./xampp/ssi.shtml ./xampp/components.php ./xampp/contrib/ ./xampp/contrib/oracle.php ./xampp/contrib/cds.xml ./xampp/contrib/soap.php ./xampp/contrib/sqlite.php ./xampp/contrib/sax.php ./xampp/contrib/postgresql.pl ./xampp/contrib/interbase.pl ./xampp/contrib/mysql.php ./xampp/contrib/dom.php ./xampp/contrib/mingstats_swf.php ./xampp/contrib/mysql.pl ./xampp/contrib/testperldbi.pl ./xampp/contrib/xmlrss.php ./xampp/contrib/mingstats.html ./xampp/contrib/sql2xml.php ./xampp/contrib/sqlite.pl ./xampp/contrib/BabelSans-B.fdb ./xampp/contrib/oracle.pl ./xampp/contrib/interbase.php ./xampp/contrib/postgresql.php ./xampp/manuals.php ./xampp/cgi.cgi ./xampp/cds.php ./xampp/webalizer.php ./xampp/biorhythm.php ./xampp/AnkeCalligraph.TTF ./xampp/head.php ./xampp/guestbook-zh.pl ./xampp/start.php ./xampp/AnkeCalligraph.fdb ./xampp/mingswf.php ./xampp/mysql.php ./xampp/guestbook-nl.pl ./xampp/navi.php ./xampp/lang.php ./xampp/security.php ./xampp/lang/ ./xampp/lang/de.php ./xampp/lang/it.php ./xampp/lang/fr.php ./xampp/lang/es.php ./xampp/lang/pt_br.php ./xampp/lang/nl.php ./xampp/lang/zh.php ./xampp/lang/no.php ./xampp/lang/pl.php ./xampp/lang/en.php ./xampp/lang/languages.php ./xampp/lang/jp.php ./xampp/splash-logo.php ./xampp/langsettings.php ./xampp/.version ./xampp/status.php ./xampp/phonebook.php ./xampp/img/ ./xampp/img/rb.gif ./xampp/img/status3.gif ./xampp/img/logo-small.gif ./xampp/img/logo-small.jpg ./xampp/img/new.png ./xampp/img/signature-kay.gif ./xampp/img/lt.gif ./xampp/img/benji-500x420.jpg ./xampp/img/status4.gif ./xampp/img/rt.gif ./xampp/img/strichel.gif ./xampp/img/head-linux.gif ./xampp/img/head-xampp.gif ./xampp/img/xampp-logo.jpg ./xampp/img/head-fuer.gif ./xampp/img/head-for.gif ./xampp/img/head-solaris.gif ./xampp/img/status2.gif ./xampp/img/status1.gif ./xampp/img/head-windows.gif ./xampp/img/logo-big.gif ./xampp/img/signature-oswald.gif ./xampp/img/status5.gif ./xampp/img/blank.gif ./xampp/img/lb.gif ./xampp/img/xampp-logo-new.gif ./xampp/img/apachefriends.gif ./xampp/guestbook-es.pl ./xampp/guestbook-de.pl ./xampp/phpinfo.php ./xampp/splash.php ./xampp/guestbook-pt_br.pl ./xampp/guestbook.dat ./xampp/charset.php ./xampp/test.php ./xampp/softwarelist.inc ./xampp/guestbook-it.pl ./xampp/cds-fpdf.php ./xampp/ssi.inc ./xampp/php.php ./xampp/sqlite/ ./xampp/sqlite/cdcol ./xampp/sqlite/phonebook.sqlite ./xampp/sqlite/.htaccess ./xampp/xampp.css ./xampp/ming.php ./xampp/showcode.php ./xampp/guestbook-fr.pl ./xampp/guestbook-en.pl ./xampp/iart.php ./.hidden ./favicon.ico ./index.html [root@benjihtdocs]# [root@benji backup]# ls -l htdocs.tar.gz; du -h htdocs.tar.gz -rw-r--r-- 1 root root343748 Nov 22 13:13 htdocs.tar.gz 340Khtdocs.tar.gz [root@benji backup]# Using gzip compression option

  41. CIS 191 - Lesson 11 tar command compression [root@benjihtdocs]# tar cjvf /opt/lampp/backup/htdocs.tar.bz2 . ./ ./webalizer/ ./sample.html ./xampp/ ./xampp/lang.tmp ./xampp/xampp.js ./xampp/index.php ./xampp/test/ ./xampp/test/xampp_ming/ ./xampp/test/xampp_ming/gif.gif ./xampp/test/xampp_ming/jpg.jpg ./xampp/test/xampp_ming/png.png ./xampp/test/xampp_ming/bitmaps.php ./xampp/test/xampp_win.png ./xampp/test/xampp_ming.zip ./xampp/perl.pl ./xampp/guestbook-no.pl ./xampp/splash-swf.php ./xampp/guestbook-pl.pl ./xampp/ssi.shtml ./xampp/components.php ./xampp/contrib/ ./xampp/contrib/oracle.php ./xampp/contrib/cds.xml ./xampp/contrib/soap.php ./xampp/contrib/sqlite.php ./xampp/contrib/sax.php ./xampp/contrib/postgresql.pl ./xampp/contrib/interbase.pl ./xampp/contrib/mysql.php ./xampp/contrib/dom.php ./xampp/contrib/mingstats_swf.php ./xampp/contrib/mysql.pl ./xampp/contrib/testperldbi.pl ./xampp/contrib/xmlrss.php ./xampp/contrib/mingstats.html ./xampp/contrib/sql2xml.php ./xampp/contrib/sqlite.pl ./xampp/contrib/BabelSans-B.fdb ./xampp/contrib/oracle.pl ./xampp/contrib/interbase.php ./xampp/contrib/postgresql.php ./xampp/manuals.php ./xampp/cgi.cgi ./xampp/cds.php ./xampp/webalizer.php ./xampp/biorhythm.php ./xampp/AnkeCalligraph.TTF ./xampp/head.php ./xampp/guestbook-zh.pl ./xampp/start.php ./xampp/AnkeCalligraph.fdb ./xampp/mingswf.php ./xampp/mysql.php ./xampp/guestbook-nl.pl ./xampp/navi.php ./xampp/lang.php ./xampp/security.php ./xampp/lang/ ./xampp/lang/de.php ./xampp/lang/it.php ./xampp/lang/fr.php ./xampp/lang/es.php ./xampp/lang/pt_br.php ./xampp/lang/nl.php ./xampp/lang/zh.php ./xampp/lang/no.php ./xampp/lang/pl.php ./xampp/lang/en.php ./xampp/lang/languages.php ./xampp/lang/jp.php ./xampp/splash-logo.php ./xampp/langsettings.php ./xampp/.version ./xampp/status.php ./xampp/phonebook.php ./xampp/img/ ./xampp/img/rb.gif ./xampp/img/status3.gif ./xampp/img/logo-small.gif ./xampp/img/logo-small.jpg ./xampp/img/new.png ./xampp/img/signature-kay.gif ./xampp/img/lt.gif ./xampp/img/benji-500x420.jpg ./xampp/img/status4.gif ./xampp/img/rt.gif ./xampp/img/strichel.gif ./xampp/img/head-linux.gif ./xampp/img/head-xampp.gif ./xampp/img/xampp-logo.jpg ./xampp/img/head-fuer.gif ./xampp/img/head-for.gif ./xampp/img/head-solaris.gif ./xampp/img/status2.gif ./xampp/img/status1.gif ./xampp/img/head-windows.gif ./xampp/img/logo-big.gif ./xampp/img/signature-oswald.gif ./xampp/img/status5.gif ./xampp/img/blank.gif ./xampp/img/lb.gif ./xampp/img/xampp-logo-new.gif ./xampp/img/apachefriends.gif ./xampp/guestbook-es.pl ./xampp/guestbook-de.pl ./xampp/phpinfo.php ./xampp/splash.php ./xampp/guestbook-pt_br.pl ./xampp/guestbook.dat ./xampp/charset.php ./xampp/test.php ./xampp/softwarelist.inc ./xampp/guestbook-it.pl ./xampp/cds-fpdf.php ./xampp/ssi.inc ./xampp/php.php ./xampp/sqlite/ ./xampp/sqlite/cdcol ./xampp/sqlite/phonebook.sqlite ./xampp/sqlite/.htaccess ./xampp/xampp.css ./xampp/ming.php ./xampp/showcode.php ./xampp/guestbook-fr.pl ./xampp/guestbook-en.pl ./xampp/iart.php ./.hidden ./favicon.ico ./index.html [root@benjihtdocs]# [root@benji backup]# ls -l htdocs.tar.bz2; du -h htdocs.tar.bz2 -rw-r--r-- 1 root root340646 Nov 22 13:14 htdocs.tar.bz2 337K htdocs.tar.bz2 [root@benji backup]# Using the bzip2 compression option

  42. CIS 191 - Lesson 11 tar command compression [root@benji backup]# ls -Slr total 2049 -rw-r--r-- 1 root root 340646 Nov 22 13:14 htdocs.tar.bz2 -rw-r--r-- 1 root root 340646 Nov 22 13:18 htdocs2.tar.bz2 -rw-r--r-- 1 root root 343748 Nov 22 13:13 htdocs.tar.gz -rw-r--r-- 1 root root 343760 Nov 22 13:15 htdocs2.tar.gz -rw-r--r-- 1 root root 706560 Nov 22 13:13 htdocs.tar [root@benji backup]# 2 steps • Conclusions: • compression option slightly better than two steps • bzip2 compresses more that gzip

  43. CIS 191 - Lesson 11 tar command compression [root@benjihtdocs]# rm sample.html rm: remove regular file `sample.html'? y [root@benjihtdocs]# tar xvf ../backup/htdocs.tar.gz ./sample.html ./sample.html [root@benjihtdocs]# cat sample.html <html> <head> <title>My first page</title> </head> <body> <h1>My first web page</h1> <p>Nothing can stop me now</p> <a href="http://google.com">My link to Google</a> </body> </html> FYI, not specifying the z option still works when restoring a file

  44. CIS 191 - Lesson 11 tar command compression [root@benjihtdocs]# rm sample.html rm: remove regular file `sample.html'? y [root@benjihtdocs]# tar xvf ../backup/htdocs.tar.bz2 ./sample.html ./sample.html [root@benjihtdocs]# cat sample.html <html> <head> <title>My first page</title> </head> <body> <h1>My first web page</h1> <p>Nothing can stop me now</p> <a href="http://google.com">My link to Google</a> </body> </html> [root@benjihtdocs]# FYI, not specifying the j option still works when restoring a file

  45. CIS 191 - Lesson 11 Class Exercise tar command • Change to the /opt/lampp/htdocs directory. • Make four backups of htdocs into the /root directory using both compression options and using post compression with gzip and bzip2. • -z option • -j option • 2 steps with gzip command • 2 steps with bzip2 command • Verify your backup by deleting, restoring and viewing sample.html for each backup above • What commands did you use for 2a and 3? [Table 17-20] • What commands did you use for 2b and 3? [Table 5-8] • What commands did you use for 2c and 3? [Table 13-16] • What commands did you use for 2d and 3? [Table 21-24]

  46. CIS 191 - Lesson 11 tar command compression c t vf x z j tarfile device tar file(s) Backups can be made to devices as well

  47. CIS 191 - Lesson 11 tar command using devices [root@benji bin]# fdisk /dev/sda Command (m for help): n First cylinder (582-652, default 582): Using default value 582 Last cylinder or +size or +sizeM or +sizeK (582-652, default 652): +500M Command (m for help): p Disk /dev/sda: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 382 3068383+ 83 Linux /dev/sda2 383 447 522112+ 82 Linux swap / Solaris /dev/sda3 448 511 514080 83 Linux /dev/sda4 512 652 1132582+ 5 Extended /dev/sda5 512 549 305203+ 83 Linux /dev/sda6 550 556 56196 83 Linux /dev/sda7 557 581 200781 83 Linux /dev/sda8 582 643 497983+ 83 Linux Command (m for help): Make a 500 MB partition

  48. CIS 191 - Lesson 11 tar command using devices Command (m for help): x Expert command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. [root@benji bin]# partprobe [root@benji bin]# Use partprobe so kernel will use new partition table

  49. CIS 191 - Lesson 11 tar command using devices Change to the directory to back up. Note /dev/sda8 is not mounted [root@benji opt]# tar cvzf /dev/sda8 . 2> /root/errors > /root/optfiles [root@benji opt]# wc -l /root/errors /root/optfiles 3 /root/errors 13282 /root/optfiles 13285 total [root@benji opt]# [root@benji opt]# cat /root/errors tar: ./lampp/logs/cgisock.2381: socket ignored tar: ./lampp/logs/cgisock.2404: socket ignored tar: ./lampp/var/mysql/mysql.sock: socket ignored You don't need to backup socket files. They are created automatically by the kernel when needed

  50. CIS 191 - Lesson 11 tar command using devices [root@benji opt]# cdlampp/htdocs [root@benjihtdocs]# rm sample.html rm: remove regular file `sample.html'? [root@benjihtdocs]# cd /opt [root@benji opt]# tar tvzf /dev/sda8 | grep sample.html -rw-r--r-- root/root 194 2008-10-24 10:13:10 ./lampp/htdocs/sample.html [root@benji opt]# tar xvzf /dev/sda8 ./lampp/htdocs/sample.html ./lampp/htdocs/sample.html [root@benji opt]# cat lampp/htdocs/sample.html <html> <head> <title>My first page</title> </head> <body> <h1>My first web page</h1> <p>Nothing can stop me now</p> <a href="http://google.com">My link to Google</a> </body> </html> [root@benji opt]# Oops! …. file gets deleted Finding file in archive Restoring deleted file from backup archive on a device Viewing restored file

More Related