1 00:00:07,200 --> 00:00:10,740 - Another awesome backup utility is rsync. 2 00:00:10,740 --> 00:00:13,080 What is so awesome about rsync? 3 00:00:13,080 --> 00:00:14,910 You can use it to synchronize files 4 00:00:14,910 --> 00:00:16,473 between different directories. 5 00:00:17,370 --> 00:00:19,230 You can also use it locally, 6 00:00:19,230 --> 00:00:21,660 uh but really the power is uh 7 00:00:21,660 --> 00:00:25,230 in synchronizing between remote systems. 8 00:00:25,230 --> 00:00:27,150 The only requirement is that remote, 9 00:00:27,150 --> 00:00:29,430 if needs to have sshd running. 10 00:00:29,430 --> 00:00:31,980 Rsync is using the sshd connection. 11 00:00:31,980 --> 00:00:34,530 It's a great utility to ensure that the contents 12 00:00:34,530 --> 00:00:36,690 of a directory, is synchronized with the contents 13 00:00:36,690 --> 00:00:38,280 of a remote directory. 14 00:00:38,280 --> 00:00:40,560 Let me show you how to use it. 15 00:00:40,560 --> 00:00:43,230 Before I begin this demo, uh you must realize 16 00:00:43,230 --> 00:00:45,303 that this demo requires two computers. 17 00:00:50,040 --> 00:00:52,710 Alright, so let's start this demo. 18 00:00:52,710 --> 00:00:55,050 I'm using mkdir files 19 00:00:55,050 --> 00:00:56,380 and then touch 20 00:00:57,270 --> 00:00:59,220 files/file. 21 00:00:59,220 --> 00:01:01,005 1 up to 22 00:01:01,005 --> 00:01:02,940 100. 23 00:01:02,940 --> 00:01:04,320 Curly brackets. 24 00:01:04,320 --> 00:01:05,970 Yeah, 25 00:01:05,970 --> 00:01:08,740 and then I can use rsync 26 00:01:11,160 --> 00:01:13,380 minus azP. 27 00:01:13,380 --> 00:01:16,380 A is for archive mode, z is through zip it, 28 00:01:16,380 --> 00:01:18,270 and p is for progress. 29 00:01:18,270 --> 00:01:21,450 To show you progress and that's convenient 30 00:01:21,450 --> 00:01:24,600 And I'm going to do that for files to student 31 00:01:24,600 --> 00:01:29,600 at 192, 168, 29, 169 32 00:01:29,880 --> 00:01:34,120 That's the other server, slash home, slash student 33 00:01:35,580 --> 00:01:37,023 slash files. 34 00:01:38,846 --> 00:01:40,929 (typing) 35 00:01:42,390 --> 00:01:43,425 And there we go. 36 00:01:43,425 --> 00:01:46,290 As you can see, a lot of stuff has been synchronized. 37 00:01:46,290 --> 00:01:47,890 Let's check on the other server, 38 00:01:49,726 --> 00:01:50,559 where you can see 39 00:01:50,559 --> 00:01:53,100 that the directory files has been created. 40 00:01:53,100 --> 00:01:56,160 And in the directory files, we have all these files. 41 00:01:56,160 --> 00:01:57,160 That's looking cool. 42 00:02:00,120 --> 00:02:03,120 Now, I'm going to create a couple more files. 43 00:02:03,120 --> 00:02:05,313 So touch on files. 44 00:02:06,270 --> 00:02:09,630 File 101 45 00:02:09,630 --> 00:02:11,433 up to 110. 46 00:02:15,000 --> 00:02:16,440 And let's do something funny. 47 00:02:16,440 --> 00:02:19,500 I'm also going to remove files, 48 00:02:19,500 --> 00:02:21,003 file 50. 49 00:02:22,920 --> 00:02:24,090 And now what is happening, 50 00:02:24,090 --> 00:02:26,793 if you run the same rsync command again. 51 00:02:29,552 --> 00:02:30,660 (typing) 52 00:02:30,660 --> 00:02:34,590 As you can see, it is uh synchronizing file 101 53 00:02:34,590 --> 00:02:37,920 up to 110, but you don't see the removal. 54 00:02:37,920 --> 00:02:38,790 And that is because, 55 00:02:38,790 --> 00:02:41,192 rsync by default, is not removing anything 56 00:02:41,192 --> 00:02:44,040 unless you specifically tell it to. 57 00:02:44,040 --> 00:02:45,000 You know uh, 58 00:02:45,000 --> 00:02:48,000 removing things automatically may lead 59 00:02:48,000 --> 00:02:50,790 to disaster, so you need to specify the 60 00:02:50,790 --> 00:02:52,740 'minus minus delete' option, 61 00:02:52,740 --> 00:02:54,363 if you want to delete as well. 62 00:02:55,860 --> 00:02:58,740 And there we can see, deleting file 50. 63 00:02:58,740 --> 00:03:00,963 This is basically, our rsync is working. 64 00:03:02,280 --> 00:03:05,193 Pretty simple, pretty straight, pretty efficient.