1
00:00:00,000 --> 00:00:17,879
Hey guys and welcome back. So the first tool or utility that I want to talk to you about

2
00:00:17,879 --> 00:00:25,219
with respect to our backup operations is the tar command. This is the tape archive utility.

3
00:00:25,219 --> 00:00:32,859
So we can with this tool ultimately group together files and or directories into one

4
00:00:32,859 --> 00:00:39,560
particular archived file otherwise known as a tar ball. Now like I say the original

5
00:00:39,560 --> 00:00:46,019
medium for this tool was going to be those magnetic tapes but we do not have to use such

6
00:00:46,019 --> 00:00:51,739
a medium of course. We can still get the benefits of the tar utility no matter where we want

7
00:00:51,740 --> 00:00:57,060
to copy our data to eventually. So when we use the tar command we have some particular

8
00:00:57,060 --> 00:01:03,219
options we have to know about the dash C flag is going to allow us to create an archive.

9
00:01:03,219 --> 00:01:08,140
This is going to be a very valuable one to understand. Whereas if we want to extract

10
00:01:08,140 --> 00:01:14,420
an archive we would use the dash X flag for extraction. If we want to list the contents

11
00:01:14,420 --> 00:01:19,859
of an archive we can use the dash T flag which is not very intuitive. You would expect something

12
00:01:19,900 --> 00:01:25,859
like say dash L but no in fact it is dash T. When we want to specify and target a particular

13
00:01:25,859 --> 00:01:31,659
file we will use the dash F flag to point to a particular file. Now when we want to

14
00:01:31,659 --> 00:01:37,659
actually extract the archive to another directory when we're doing the extraction we want to

15
00:01:37,659 --> 00:01:43,780
use dash capital C. So small case C is going to allow us to create an archive. Capital

16
00:01:43,780 --> 00:01:49,620
C is going to allow us to choose a directory to extract that archive to. Now you also may

17
00:01:49,660 --> 00:01:56,140
remember tar does not have to be used with compression but of course it very often is

18
00:01:56,140 --> 00:02:00,939
because this is very efficient. If we want to invoke different types of compression we

19
00:02:00,939 --> 00:02:08,099
have particular flags. The dash Z flag is going to allow us to use the GZ compression.

20
00:02:08,099 --> 00:02:14,939
Whereas the dash lowercase J that is going to allow us to use BZ2 base compression and

21
00:02:14,979 --> 00:02:21,460
if we want to use dash capital J that will allow us to use XZ compression. So how about

22
00:02:21,460 --> 00:02:27,300
we actually use this utility and try some backups then. So what we'll do here is I'll

23
00:02:27,300 --> 00:02:33,780
go to my command line here we have right here. Now remember we talked about in the very first

24
00:02:33,780 --> 00:02:38,860
nugget some of the locations whereby we would want to backup. So that may be things like

25
00:02:38,860 --> 00:02:45,860
the etsy directory. It also may be your actual home directory. We also might want to go into

26
00:02:45,860 --> 00:02:52,860
the var directory and backup maybe say the mail file or perhaps maybe backup the backups

27
00:02:52,860 --> 00:02:58,380
directory. So how about we actually give an example of doing such a thing then. So I'll

28
00:02:58,380 --> 00:03:02,540
go back to my main directory right here and what I will do is I will say tar and I will

29
00:03:02,539 --> 00:03:10,139
use dash C that's going to create an archive. We will use V to be verbose. We will use dash

30
00:03:10,139 --> 00:03:17,979
lowercase J. This means that the archive will be filtered via the BZ2 compression and we'll

31
00:03:17,979 --> 00:03:23,739
use F to target a particular file IE. What will the file actually be called. So what I'll call

32
00:03:23,739 --> 00:03:31,099
this is just simply backup and I'll give it the extension TBZ. That is because it's going to be a

33
00:03:31,180 --> 00:03:37,819
tar ball with BZ compression. Keep things nice and clear and now what I want to do is to specify

34
00:03:37,819 --> 00:03:46,219
what it is I actually want to backup. So I could target say for example the home IPv0 directory.

35
00:03:46,219 --> 00:03:53,579
I could target the var log directory as well as maybe the var mail directory and maybe say the var

36
00:03:53,579 --> 00:03:59,819
backup directory and maybe say also the etsy directory. So these are all the targets that I

37
00:03:59,819 --> 00:04:04,859
want to include. So if I just hit enter check this out. What we're actually going to be doing here

38
00:04:04,859 --> 00:04:10,939
is creating this particular archive. So this may take a little bit of time. Oh and we actually

39
00:04:10,939 --> 00:04:15,739
have a failure status. This will no doubt be because I need to have super user privileges to

40
00:04:15,739 --> 00:04:21,740
access some of these locations. So what I'll do here is I'll just delete this backup. Let's go up

41
00:04:21,740 --> 00:04:27,899
the errors. Let's arrow up and I'll use super user privileges. Type in my password. Try that again.

42
00:04:27,899 --> 00:04:33,259
Okay perfect. So now we actually don't get our errors and we can see here we actually have

43
00:04:33,819 --> 00:04:41,019
our backup tar ball which is being compressed with BZ compression. Now like I say if I wanted to

44
00:04:41,019 --> 00:04:48,060
extract this backup then I could do that using the X flag. Now also if I wanted to target a

45
00:04:48,060 --> 00:04:54,539
particular backup directory let's maybe create a directory just called my backups. Now we have

46
00:04:54,620 --> 00:05:00,379
this new directory right here. What I can now do is I can use that same command tar. This time I'm

47
00:05:00,379 --> 00:05:06,460
not going to say dash C to create a directory or to create an archive. Should I say I'm going to use

48
00:05:06,460 --> 00:05:14,060
dash X to extract a tar ball and I will use V to be verbose. You want to use J because it is using

49
00:05:14,060 --> 00:05:22,379
BZ to compression and I will say F to target the file and now just specify the file backup.tbz. Now

50
00:05:22,379 --> 00:05:27,420
I actually want to extract this to a particular location. My backups. Can you remember the flag

51
00:05:27,420 --> 00:05:33,659
we're going to use to extract to a particular directory that is going to be dash capital C

52
00:05:33,659 --> 00:05:41,100
and now I can just give the path of home IPv0 my backups. So if I hit enter this is going to

53
00:05:41,100 --> 00:05:45,980
extract all this information which will take a little bit of time and it's going to dump that

54
00:05:45,980 --> 00:05:52,620
information into that directory. Okay so if we do an LS we can see what we have here if I go into

55
00:05:52,620 --> 00:05:58,939
my backups now. I do an LS check this out we actually have my home directory the var directory

56
00:05:58,939 --> 00:06:04,460
and the exit directory so if I go into say for example CD var we don't have all the contents

57
00:06:04,460 --> 00:06:10,220
of that but we do have the directories or the sub directories that we actually targeted say for

58
00:06:10,220 --> 00:06:15,180
example the mail that we wanted to backup the log as well as the backups directory and again if we

59
00:06:15,180 --> 00:06:20,939
go into these particular folders we can do an LS we can see we have all of these particular files

60
00:06:20,939 --> 00:06:28,220
which are here and again go into log LS all these files we go back out same if I go into my home

61
00:06:28,220 --> 00:06:34,620
directory we see the IPv0 directory and again we have a backup of my directory structure right here.

62
00:06:34,620 --> 00:06:39,740
So as we can see here using the tar command it's going to be very valuable when we want to target

63
00:06:39,740 --> 00:06:44,780
particular files and directories for backup we can ultimately group everything together

64
00:06:44,859 --> 00:06:51,739
into one nice neat file and we can extract that file or if we want we can share that file or

65
00:06:51,739 --> 00:06:57,179
transfer that file to another server. Now how on earth would we actually go about transferring

66
00:06:57,179 --> 00:07:02,379
this file to say for example another remote server? Well the good news is that that is what we're going

67
00:07:02,379 --> 00:07:06,619
to be talking about in the very next nuggets I hope this has been informative for you and I'd like

68
00:07:06,620 --> 00:07:11,259
thank you for viewing.

