 Backing up your computer is one of the most important things you can do and I've talked about this on the channel many times and I keep preaching about it because if you were to lose data and you didn't have a backup You'd be in a very tight spot chances are you're never going to get that data back And that could be devastating for any number of reasons whether you're losing pictures or tax documents or whatever Losing data is horrible. So Please please have a backup, but the question is how do you back up? So a few weeks ago, I made a video talking about 10 tips or tricks on how to back up your system and one of those tips or tricks was a program called our sink now our sink is a Command line program that basically allows you to copy files and directories from one place to another That's basically what our sink does at the basis level. That's all it does and it really doesn't matter where those Files are so you can use things like SMB or SSH if you wanted to do to Transfer your backups over SSH to another computer or to a NAS or whatever you could do that with our sink very easily So what I thought I would do today is take you through the very basics of our sink and when I say the very basics I really do mean the very basics I'm going to take you through four flags that you need to know or four options that you need to know to use our Sink and that's going to be like the just scratching the surface because if you were to look at the manual page for Our sink you'd find that it has approximately 100 different options that you could use and I'm Probably underestimating that just a little bit. There are a ton of options There's no way we could cover them all in this video without being here for several days So we're not going to do that I'm going to show you the four most important ones and I'll point you to the man page if you want to know more So let's go ahead and jump in I'm going to show you the basics of how to use our sink So the first thing that we should talk about is Installation if you are using Linux chances are our sink is already installed on your system Most distros have our sink pre-installed if it does not it should be in your distros repositories I can't think of a single distribution out there that doesn't have our sink in it So if you can't find it on your system download it through your package manager It'll be very simple to do once you have it installed then you have to get to actually using it So let me show you what our sink actually looks like so at its basis our sink Which is just done with the rsync command simply copies directories from directory 1 to a directory 2 now Like I said these can be in any place you want so it can be an SMB server somewhere else It can be your SMB on your computer. It can be SSH somewhere else whatever it can be on your system It can be an external hard drive It doesn't merely matter if you want to learn how to do the SSH and the SMB stuff all that stuff is covered in the man page But at its basest form what our sink does is it copies files and directories from one directory to another if you run this and Those directories actually existed then you'd be set to go But obviously if that was all there was to it this wouldn't be much of a tutorial that's very simple and much too simple So let's make this a little bit more complicated So there are four flags as I said that you'll want to know to use when you use our sink So the first one is the dash a option now. This is the easiest one to explain Basically what the dash a our option does is it preserves all the permissions of the files and directories that you're copying So things like the ownership the read write executable permissions for each file that way If you were to have to restore your data back onto a Linux machine or any other machine Those permissions would still be there as they were when you copied them If you were to not use the dash a flag you would find yourself probably in a world hurt when you tried to Restore that data simply because it would probably not preserve the appropriate permissions The permissions would probably take the form of whatever drive you were copying it to so if you were to transfer it to an ntfs drive The permissions for ntfs are really kind of weird So if you were to transfer your data there without preserving the permit permissions when you transfer the files and stuff back Those permissions and the ownership and stuff would be completely different. So use the dash a option The next flag or the next option that you want to use is the v flag Basically what the v flag does is it allows you to see a verbose output of the arson command as it runs So what this allows you to do is see exactly what our sink is doing and if there are any errors along the way So if there are folders or files that were deleted while our sink was running It will show you an error or if it was unable to copy Your files or folders from one place to another it will tell you exactly why it couldn't do that So with the v flag you'll be able to see that information without the v flag that information would not be there It just would run and then tell you it was completed The next one that is important is the dash dash delete option now This is the option that I've had the hardest time in this video explaining I've tried to do this now five times and every time I try to explain what the dash dash delete option is I've pretty much failed. I've made it much too complicated and really it's very simple. So if we have this here Basically what the dash dash delete option does is that it syncs those two directories up And if you've ever heard the term delta update or delta backup Basically, that's what the dash dash delete option does why this is important is because let's just say you have been using your computer for a long time And you've made many many backups. So I'm going to actually show you my backups If I do an ls here, you'll see that I have many many backups and each one of these has a lot of folders and directories in them And most of them are almost precisely exactly the same, you know, there's only going to be some small changes between the one that was done on July 14th and the one that was also done on July 14th. Why did those exactly the same day? I'm not sure usually I don't do two backups in a day But apparently that one that I did so in this case, it's actually a very good Reason why I should use the dash dash delete option. I don't use it obviously I prefer to have separate backups of everything Every time I run rsync But for most people that's not going to be feasible because this takes up a lot of space by using the dash dash delete option Basically, what's happening there is that it's going to compare directory one directory two So directory two in this case in this situation already exists So you've ran rsync one time and now you're running a second time our third time or whatever And you're running it with the same command with the same directory and pass structure Basically what the dash dash delete option is going to do is compare directory one to directory two And then make the changes in directory two so that it's Precisely exactly the same as directory one, but without transferring everything over So for example, my music collection my music collection is about 100 gigabytes worth of Music if I were to have my music collection in directory one And also in directory two what dash dash delete would do is compare the music directory in Der one and der two and then just transfer over the changes between them So let's just say since the last time I've ran rsync I've downloaded 10 new songs instead of transferring over the entire music directory into directory two again Basically, what's going to do is just transfer over those 10 new songs. That's what it does So it will also if I've deleted things from directory one So I've deleted 10 songs from my music directory. It will just delete those 10 songs from directory two That's what the dash dash delete option does not as hard as it sounds or as complicated as it sounds, but That's what it does and it's a very Good solution if you're only ever going to use one directory as your backup location It's so your backup location doesn't balloon in size with a whole bunch of different versions of Files, okay So those are the three most important flags that you'll want to use if you were to just do this You'd be well on your way and you could just use that now There is one extra one that I wanted to talk about so if I were to show you my rsync script There is this flag here called dash dash exclude Now this is not as big of a deal if you use the dash dash delete option But if you don't the dash dash exclude option basically just tells rsync do not sync this particular path So don't don't back up my music don't back up my isos don't back up that local that share That's where steam stores the games don't back up that cash don't back up that var And so on and so forth Now there is a way to combine those so that you only have to use dash dash exclude once I just haven't got around to doing it yet But that's what the dash dash exclude option does so if if you're going to be like me and have a whole bunch of Directors with your backups and it sorted by day Whatever you're not going to want a whole bunch of copies of your music collection It's unnecessary. Have a couple You don't need 50 of them. Okay. You just don't Same thing with your isos. You don't need to back up those at all At least I don't think I need to so I don't want those things to take up a whole bunch of space So I just exclude them from my rsync script So the dash dash exclude option is a really nice one if you have Large files that you don't want transferred over in your rsync script So that is the fourth flag that I consider most important now That's just really scratching the surface of rsync if we were to go into the man page for rsync And scroll down to the option section. There are approximately six thousand lines. Maybe even a little bit more In this man page. So if you're into some good reading read the man page There's a lot of stuff here a lot of interesting stuff too. I don't want to Scare you away by saying it's six thousand lines But there's just a lot of stuff But the the most important part of the man page is going to be the option summary And as you can see if we scroll down here, there are a ton Of options that you can choose from some of the stuff is going to be So you can like change the owner of the group change or preserve the device files and things like that copy the device contents Preserve the access times and stuff like that. So there's just a ton of stuff here that you can do Most of the stuff here you're never going to ever use But there are a few that are really interesting things to point out So things like the the delete before and the delete after that allows you to Basically control what that dash dash delete flag compares When it comes to like the time of the file and the time of creations things like that The dash dash delete excluded would also delete excluded files from the destination directory So if you were to have been using rsync for quite some time But then discover the dash dash exclude flag you could then run dash dash delete excluded And it would delete the excluded files that you just created from your backup location So that's one other option. There are maximum sized Flags if you wanted to only back up certain size of files things like that And it just goes on and on and on and on so there is a ton of stuff here when it comes to rsync that you can do and I highly recommend at least perusing The man page because there's a ton of stuff here that I haven't Comments on or explained whatsoever. In fact, the vast majority of this stuff I've never used and I think that that's going to be the case for the vast majority people The four that I've covered are going to be the four ones that most people use You may end up finding a few others that you want to kind of throw in there if you have other needs But those four that I talked about are the main four that most people probably use so That is rsync at its basic basic form. So what does this actually look like running? Let me show you So if I were to run my rsync script, I've already showed you what that is. Let me show you let me show it to you again This is what my rsync does. It basically just Declares the date gives the backup directory ignore this one for now That that I've never actually gotten to work and then it makes the Directory which is basically the backup directory that I'm going to be using So it creates it on my external hard drive with the file name of the date of the backup And then it just runs rsync runs rsync dash av. So it's going to use the archive and the verb only mode and then it had It excludes Several files It's going to back up my home directory And then it's going to back it up into this place right here using those variables So that's what my rsync script does if you want to use my rsync script You can it's up on git lab Just make sure you get the paths right because obviously your paths are going to be different So i'm going to run rsync dot sh if I can spell Which I can't wow But a long day all right I'm going to run this And it's that's what rsync looks like with the verbose flag without the verbose flag you wouldn't see any of this stuff So basically all this is doing is it's running rsync. It's transferring this Each file here that it's showing into The appropriate file in the the destination directory and once it's done It moves on to the next one and over and over and over again until it's all the way done So that is what rsync looks like when it's done In my case it usually takes around four or five minutes And obviously the more stuff you're transferring from directory one to directory two the longer it's going to take Obviously, it's not so much the number of files, but the size of files the Bigger the file longer it's going to take to transfer So that's what rsync looks like running And as you can see here, it's gotten to a file where it's taking a little while. So that's probably one A file that I could exclude if I wanted to I mean doing that because I don't really need a cache But anyways, that's what rsync looks like as I said This is a very very brief overview of how to use rsync as you saw in the man page There's a ton of stuff there that I could have talked about and we could have been here for a very long time When it comes to actually showing you some of those flags And I wouldn't have been a very good person to go over a lot of that stuff because I've never used a lot of that stuff Most of the stuff is just things that I wouldn't need The script that I have works perfectly fine for me I should use the dash dash delete option, but I just don't If you have comments about rsync or any of this stuff, you can leave those in the comment section below I'd love to hear from you if you have questions. I'll try to answer them in the comment section below You can follow me on twitter at linuxcast. You can follow me on masted on our odyssey Those links will be in the video description You can you can support me on patreon at patreon.com slash linuxcast Just like all these fine people. Thanks to everybody who does support me on patreon youtube. You guys are all Absolutely amazing without you the channel just would not be anywhere near where it is right now So thank you so very much for your support. Thanks everybody for watching. I'll see you next time