1
00:00:00,090 --> 00:00:01,230
Now, as we continue to add things

2
00:00:01,230 --> 00:00:02,550
to our backup drive,

3
00:00:02,550 --> 00:00:06,990
we'll notice that the spaces rapidly being consumed.

4
00:00:06,990 --> 00:00:09,060
Now, the best thing we should do in this scenario

5
00:00:09,060 --> 00:00:10,560
is to compress the files.

6
00:00:10,560 --> 00:00:12,600
So we're going to go over three different methods

7
00:00:12,600 --> 00:00:14,040
of compressing these files.

8
00:00:14,040 --> 00:00:16,740
We're going to go through and use the gzip, the XZ method,

9
00:00:16,740 --> 00:00:18,363
and the bzip2 method.

10
00:00:19,230 --> 00:00:20,610
All right, so the first thing we're going to do,

11
00:00:20,610 --> 00:00:22,360
we're going to go to our backup drive.

12
00:00:24,510 --> 00:00:25,830
Okay, I'm going to list out.

13
00:00:25,830 --> 00:00:28,770
Now, if we see our employee data.tar file,

14
00:00:28,770 --> 00:00:30,660
it's roughly 10 kilobytes.

15
00:00:30,660 --> 00:00:34,173
Okay, so we're going to compress this using gzip first.

16
00:00:37,680 --> 00:00:39,390
So we're going to use the sudo bash command.

17
00:00:39,390 --> 00:00:42,120
So you remember, when we use the C command,

18
00:00:42,120 --> 00:00:45,880
this will allow us to simultaneously create the file

19
00:00:47,880 --> 00:00:49,710
without deleting the current one

20
00:00:49,710 --> 00:00:52,800
'cause by default, it replaces the current one

21
00:00:52,800 --> 00:00:53,950
and we don't want that.

22
00:00:55,260 --> 00:00:59,250
Okay, now we see it compressed by 97.5%.

23
00:00:59,250 --> 00:01:00,400
So let's list this out.

24
00:01:06,060 --> 00:01:11,060
And now we see that it's now from 10 kilobytes to 290 bytes.

25
00:01:11,220 --> 00:01:13,170
That is a significant reduction.

26
00:01:13,170 --> 00:01:15,540
And this should be a practice that you use frequently

27
00:01:15,540 --> 00:01:17,550
when you're storing data.

28
00:01:17,550 --> 00:01:18,960
Next, we can go through the process

29
00:01:18,960 --> 00:01:22,800
of uncompressing this archive with tar command.

30
00:01:22,800 --> 00:01:24,270
And one good thing about the tar command,

31
00:01:24,270 --> 00:01:27,480
it allows us to use the z option

32
00:01:27,480 --> 00:01:30,300
which will decompress simultaneously

33
00:01:30,300 --> 00:01:32,520
so we won't have to decompress

34
00:01:32,520 --> 00:01:36,000
and then remove the files from the tar.

35
00:01:36,000 --> 00:01:37,530
We can do it all at once.

36
00:01:37,530 --> 00:01:38,530
So we list this out.

37
00:01:41,910 --> 00:01:44,190
We can see the employee info folder

38
00:01:44,190 --> 00:01:45,690
has been removed from the tar

39
00:01:45,690 --> 00:01:48,543
and it's also decompressed simultaneously.

40
00:01:50,280 --> 00:01:54,333
Next, we're going to compress and decompress with the XZ tool.

41
00:01:55,170 --> 00:01:58,353
So again, let's do sudo, new xz,

42
00:01:59,937 --> 00:02:02,250
and the -k, that means we're going to keep it.

43
00:02:02,250 --> 00:02:05,103
And again, v always means revolve for the most part.

44
00:02:06,690 --> 00:02:09,360
Okay, we see here that it's 100% complete.

45
00:02:09,360 --> 00:02:11,580
That's the progress of the compression.

46
00:02:11,580 --> 00:02:13,530
And it's .03, which indicates

47
00:02:13,530 --> 00:02:16,140
that it's 3% of the original file size.

48
00:02:16,140 --> 00:02:21,140
But to note the differences between XZ and gzip,

49
00:02:21,360 --> 00:02:23,670
XZ is usually better at compression,

50
00:02:23,670 --> 00:02:25,770
meaning, it's a higher ratio

51
00:02:25,770 --> 00:02:28,620
so it can make the file a lot smaller than gzip,

52
00:02:28,620 --> 00:02:31,323
but gzip has an advantage in speed.

53
00:02:32,220 --> 00:02:34,860
All right, let's list this out really quick.

54
00:02:34,860 --> 00:02:37,770
In this case, our starting file sizes were so small.

55
00:02:37,770 --> 00:02:40,110
The XZ actually ended up being a bit larger

56
00:02:40,110 --> 00:02:41,370
than gzip this time.

57
00:02:41,370 --> 00:02:45,150
But normally, XZ will have these smaller file sizes.

58
00:02:45,150 --> 00:02:49,560
All right, next we're going to decompress this XZ file,

59
00:02:49,560 --> 00:02:50,730
now a tar.

60
00:02:50,730 --> 00:02:52,560
Earlier we used the Z command.

61
00:02:52,560 --> 00:02:54,990
Now this time, we're going to use the capital J,

62
00:02:54,990 --> 00:02:59,730
that's going to allow us to do that, .xz.

63
00:02:59,730 --> 00:03:01,950
All right, that went through successfully.

64
00:03:01,950 --> 00:03:03,750
Let's list this out.

65
00:03:03,750 --> 00:03:06,570
And we see the employee info is back in there.

66
00:03:06,570 --> 00:03:09,220
Last but not least, we're going to use the bzip command.

67
00:03:10,080 --> 00:03:12,993
And this is a nice balance between XZ and gzip.

68
00:03:14,280 --> 00:03:17,460
So we're going to use -k, that will keep the file,

69
00:03:17,460 --> 00:03:18,573
employee data.tar.

70
00:03:21,000 --> 00:03:24,030
All right, and again, now we're going to decompress it.

71
00:03:24,030 --> 00:03:27,963
We're going to use the tar, okay xj, tar.bz2.

72
00:03:33,300 --> 00:03:35,340
And again, that listed it out.

73
00:03:35,340 --> 00:03:37,321
List this out.

74
00:03:37,321 --> 00:03:40,263
Now we can see the employee info is back in there.

75
00:03:42,060 --> 00:03:44,460
Okay, just walk through how to compress files

76
00:03:44,460 --> 00:03:46,080
using the tar files

77
00:03:46,080 --> 00:03:48,720
and how the tar command implements options

78
00:03:48,720 --> 00:03:52,170
that allows us to decompress as well as extract the file

79
00:03:52,170 --> 00:03:54,150
from the tar itself.

80
00:03:54,150 --> 00:03:56,580
Now, typically the XZ compression method

81
00:03:56,580 --> 00:03:57,870
compresses things a lot better,

82
00:03:57,870 --> 00:04:00,210
but we see this time with the gzip,

83
00:04:00,210 --> 00:04:02,763
it actually won out on this particular test.

84
00:04:03,660 --> 00:04:06,990
But overall, the XZ is the better method,

85
00:04:06,990 --> 00:04:09,150
gzip is the best for speed

86
00:04:09,150 --> 00:04:12,690
and the bzip2 is the best balance between the two.

87
00:04:12,690 --> 00:04:14,310
Thank you for sticking me through this lesson

88
00:04:14,310 --> 00:04:15,960
and I'll see you in the next one.

