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 packets, 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,339
Two options that I should talk about in the context of rsync are minus-n.

17
00:01:24,339 --> 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:44,620
Let me show you.

23
00:01:44,620 --> 00:01:59,699
So I'm going to start using scp-student-add-192.168.29.139://etc/.

24
00:01:59,699 --> 00:02:08,419
Then let me use ls-l hosts, and there we have the host file from the remote machine.

25
00:02:08,419 --> 00:02:14,539
Now the other example is rsync.

26
00:02:15,460 --> 00:02:17,460
So how are you going to use rsync to synchronize?

27
00:02:17,460 --> 00:02:21,460
Well, let me use rsync-avz.

28
00:02:21,460 --> 00:02:22,460
Hang on.

29
00:02:22,460 --> 00:02:32,580
Before I'm doing that, let me use touch-home-student-hello-file, uppercase, so that it's easy to see.

30
00:02:32,580 --> 00:02:41,100
And then rsync-a for archive mode, v for verbose, z because it's cool to apply compression,

31
00:02:41,259 --> 00:02:45,699
but that's not really needed if you don't synchronize very much.

32
00:02:45,699 --> 00:02:55,460
Slash home slash student with a slash behind it to slash student-add-192.168.29.139

33
00:02:55,460 --> 00:02:59,139
colon slash home slash student slash.

34
00:02:59,139 --> 00:03:03,539
Please do not forget the slashes.

35
00:03:03,539 --> 00:03:09,619
And then it is prompting for the user student password, and it will synchronize files.

36
00:03:09,740 --> 00:03:25,580
So if I would use ssh student-add-192.168.29.139 ls-l slash home slash student, then we should

37
00:03:25,580 --> 00:03:27,339
see the result.

38
00:03:27,339 --> 00:03:28,339
There we go.

39
00:03:28,339 --> 00:03:29,419
The result is there.

40
00:03:29,419 --> 00:03:31,179
So that is how rsync is working.

