1 00:00:00,000 --> 00:00:12,000 So if you create a backup, you better store it off-site, because if your server goes down, 2 00:00:12,000 --> 00:00:16,400 your backup will be lost and you can't restore it anymore. 3 00:00:16,400 --> 00:00:20,840 Now to store files off-system, Linux has a couple of utilities available. 4 00:00:20,840 --> 00:00:27,420 First, there is SFTP, which uses an SSH process that is running on a remote system to upload 5 00:00:27,420 --> 00:00:31,100 files using traditional FTP commands. 6 00:00:31,100 --> 00:00:37,099 I can see one use case only, and that is if you have used traditional FTP very often. 7 00:00:37,099 --> 00:00:40,259 But nowadays, that's not very common anymore. 8 00:00:40,259 --> 00:00:45,340 You might like SCP, which is also part of the SSH package, and it can be used to copy 9 00:00:45,340 --> 00:00:47,619 individual files over. 10 00:00:47,619 --> 00:00:51,400 Very convenient on a file-by-file basis. 11 00:00:51,400 --> 00:00:55,820 But if you really want it to be powerful, you better use rsync. 12 00:00:55,820 --> 00:01:00,880 rsync is used to synchronize files over to and from remote servers, and it does an excellent 13 00:01:00,880 --> 00:01:06,040 job making delta-syncs, meaning that it will synchronize differences only. 14 00:01:06,040 --> 00:01:16,080 Use something like rsync-avz home-student to student-add-192.168.29.139://home-student, 15 00:01:16,080 --> 00:01:20,080 and your directory will be synchronized with the remote directory. 16 00:01:20,080 --> 00:01:24,320 Two options that I should talk about in the context of rsync are minus-n. 17 00:01:24,320 --> 00:01:26,139 Minus-n is doing a dry-run. 18 00:01:26,139 --> 00:01:29,019 It will show you what it will do without doing it. 19 00:01:29,019 --> 00:01:34,300 The second option is minus-delete, and that will make sure that if a file in the source 20 00:01:34,300 --> 00:01:38,800 doesn't exist, but does exist in the target, it will be deleted. 21 00:01:38,800 --> 00:01:42,860 In my opinion, that's a pretty dangerous option, so better don't use it. 22 00:01:42,860 --> 00:01:43,860 Let me show you. 23 00:01:44,599 --> 00:01:59,720 So I'm going to start using scp-student-add-192.168.29.139://etc/. 24 00:01:59,720 --> 00:02:08,419 Then let me use ls minus l hosts, and there we have the host file from the remote machine. 25 00:02:08,419 --> 00:02:14,520 Now the other example is rsync. 26 00:02:14,520 --> 00:02:17,320 So how are you going to use rsync to synchronize? 27 00:02:17,320 --> 00:02:21,479 Well, let me use rsync-avz. 28 00:02:21,479 --> 00:02:23,759 Hang on before I'm doing that. 29 00:02:23,759 --> 00:02:32,600 Let me use touch-home-student-hello-file, uppercase, so that it's easy to see. 30 00:02:32,779 --> 00:02:41,100 Then rsync-a for archive mode, v for verbose, z because it's cool to apply compression, 31 00:02:41,100 --> 00:02:46,059 but that's not really needed if you don't synchronize very much. 32 00:02:46,059 --> 00:02:56,979 Slash home slash student with a slash behind it to slash student-add-192.168.29.139://home 33 00:02:56,979 --> 00:02:59,380 slash student slash. 34 00:02:59,380 --> 00:03:03,720 Please do not forget the slashes. 35 00:03:03,720 --> 00:03:09,759 And then it is prompting for the user student password, and it will synchronize files. 36 00:03:09,759 --> 00:03:25,160 So if I would use ssh student-add-192.168.29.139 ls minus l on slash home slash student, then 37 00:03:25,160 --> 00:03:27,320 we should see the result. 38 00:03:27,320 --> 00:03:28,320 There we go. 39 00:03:28,460 --> 00:03:29,460 The result is there. 40 00:03:29,460 --> 00:03:31,179 So that is how rsync is working.