The COMPLETE BTRFS Snapshot Guide

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right how's it going y'all so today i'm finally doing my full deep dive into synology snapshots this is a video i've been meaning to do for a while because it is so crucial i've done one in the past but this one is going to be so much better i've learned so much more and i've gotten a lot better videos and i'm going to do a full deep dive into synology's best feature this is a feature every single synology owner should be using if they have a btr of s volume it is that good there are pretty much no instances where i do not recommend people use snapshots there's one or two and i'll talk about those later but if you've got a btrfs file system you absolutely should be using snapshots snapshots protect you from so many different things they protect you against dumb delete ransomware just messing up they protect you against files accidentally getting corrupted by programs it is so powerful and so useful that is the first thing i set up anytime i have a new client i always make sure they have snapshots enabled because they can be a life saver what snapshots allow you to do is snapshots allow you to roll back the clock on your entire file system without actually using that much data it uses the minimal amount of data possible just based off of the deltas it allows you to roll back to old versions of files without really having to carry around all these massive files instead it only carries around the differences from the changes and it can be a real life saver i always recommend setting this up if at all possible because it just runs the background and you will forget about it until the day you need it and then when the day you need it you go oh shoot my computer just got hacked and it encrypted all the files on my nas oh hey an employee got mad and deleted the entire file system or anything it just allows you to so easily roll back to a good state of your entire file system and it's just peace of mind i will say this is not a backup you really need to be backing up your crucial files family photos tax documents everything that you really rely on but this is additional peace of mind it is so much easier to restore from a btrfs snapshot than a backup because a btrfs snapshot can be restored from instantly it is such a great feature and i really highly recommend every single user who has btrfs use it alright and so before we get in the rest of this video i'd like to thank aura for sponsoring this section of the video in 2020 49 million americans were fell victim to identity theft and ended up costing them a combined 56 billion dollars these are not people who just fell for phishing scams or had bad passwords 37 billion records got hacked in 2020 alone from major social media sites crypto exchanges pharmacies phone and internet providers all these got hacked and because of this unless you want to completely stay offline preventing your personal information from being leaked online might be completely out of your control that's why i'm excited to partner with aura who's sponsoring the section the video ora's app uses ai and machine learning to constantly protect your identity online you simply tell or your email account your account numbers as well as your phone numbers and aura's machine learning algorithm will continuously scour the dark web data brokers and even public records to alert you to criminal activity fast aura's app also features a vpn which allows you to stay anonymous online even from your isp someone becomes a victim of identity theft every 14 seconds don't be the next one let aura protect you all right and so as part of their thing they also will scour the dark web as i said and actually find leaked passwords and things and yeah this is the dashboard that shows it and i only gave them a couple of my email accounts to start out with and i already have 34 reports and these are actually i looked through these some of these are passwords i was actually using for a while and it's quite disturbing to see your passwords that you were using in plain text just showed you like hey this is just online so i would love to see if anybody can beat that record put that in the comments below but that is a lot try aura for free for two weeks to see if your information has been leaked on the dark web you can use my link down in the description start your free trial at aura.com space racks alright thank you so much for aura for sponsoring this section of the video now back to btrfs snapshots all right and so now before we get into nitty gritty of btrfs snapshots we need to talk about who can use btrfs snapshots so to use btr of snapshots you need a btrfs file system and so most of the j models those cheaper models from synology do not have btrfs and some of the really older plus models also do not have btrfs but if you have a somewhat modern plus model you almost certainly have the option for btrfs now when you're building your first volume especially if you did this on dsm6 on dsm 7 they really push you to btrfs but back in the day on dsm-6 it was quite common to hey i actually want to do ext4 instead of btrfs because they didn't really push you as much as they should have to btrfs so if you currently have an ext4 file system you unfortunately cannot easily just switch it on over to vtrfs the best way i've found to do this is honestly to back everything up using hyper backup and do a second backup of all of your really crucial photos and everything you cannot live without format your nas reinstall it with btrfs and then put everything back on it is a huge pain and i actually had to go through it myself because when i first started out i started out with ext4 and how to switch over but if you have the ability to do it and it's not a huge deal i would highly recommend it it is well worth it because of how great these features are and how much a btrfs can protect your data all right and so now with out of the way let's talk about what btrfs snapshots are in general so btrfs snapshots are part of the btrfs file system which is a copy on write file system you can think of them very similar to zfs snapshots they really work almost exactly the same and so essentially what a snapshot is is a snapshot uses the really cool features of a copy on write file system to essentially only have to store deltas to restore any previous version of a file so what that means is say you edit a document instead of just totally deleting the document and saving it somewhere else which is what normal file systems do btrfs instead just goes okay the document's the same thing as it was just with this little change and so instead of deleting the original document it'll just save that little change in a separate part of the disk and once that thing has been written to the disk it'll say okay next time you ask for that document we're going to send him the original data except for that part that changed when he gets that part that changed we'll send them to the new location but with btrfs snapshots that original section of data that changed isn't deleted quite yet instead it sticks around until the last snapshot that's using it is removed and so because of that you are able to browse exactly how your file system was binarily exactly how your file system was at any time by just referencing those old data pointers and so it is so powerful and protects you from so much stuff while being incredibly lightweight they're as lightweight as it gets without doing full-blown deduplication it is absolutely awesome and one of the most useful features out there i recommend every single synology user implement btr of snapshots if they're able to so for more simplified explanation and what really i think helps a lot of people understand how btr of snapshots work especially when it comes to space is think of them just like the recycling bin on your computer generally when you delete a file on your computer it is not immediately gone instead when you delete it actually sends it to the recycling bin right and so you do not immediately your space back because that file is not actually gone it's just now in the recycling bin and so until you empty the recycling bin you do not get any space back and that is exactly how btrfs snapshots work and so if i take a snapshot and then i delete a file that snapshot is holding onto the date of that file because if it removes the data from that file your nas now no longer knows what it is and can't restore from it so as long as that snapshot exists that snapshot is going to hold on to that data until it is deleted so essentially your file system will keep that data on disk meaning you won't get the space back until the very last snapshot that's referencing that data is removed and so that's exactly how the recycling bin works your computer does not give you your space back until the recycling bin is emptied they're very much the same way and so essentially what you can think of btrfs snapshots are is it's just a recycling bin that is way better than any other recycling bin you've ever seen it is great for that because it also allows changes so normally if you just change a document it's not going to end up in the recycling bin because you didn't delete the document you just changed it with btrfs you actually get to have that old version document that's really the only difference but that's how you should think about this when you're thinking about space alright and so now let's finally go in and let's open up snapshots so you can download the package from the package center and it will download snapshot replication there's two parts to snapshots there's snapshots locally and snapshots replicated for the most part this video we're going to be talking about local snapshots but replicated snapshots are absolutely awesome and they're a crucial part of an advanced 321 backup solution for businesses that i set up quite often so when you open this up the very first time you're likely to see a message that say hey your file system has access times enabled you should disable that for peak performance so access time is something that some people use but the vast majority people never actually use essentially what it is is every single time you open a file the file system will log hey this file was last opened at this time it's useful for some things say you want to figure out what documents have not been used in a while or opened you can do things like that but in reality not that many people ever use it so it's not that necessary but it can actually hinder you because every single time you open a file you're now changing the file most time when you open a file you're just reading it so you don't actually change it but now when you're opening a file you're actually changing it and so that forces btrfs to monitor so many more changes than necessary and so because that the first time you open snapshots it'll tell you hey you probably want to remove those and i actually recommend most people remove access time unless they need it the way you do that is very simple you just go ahead and open up your storage manager you go into your volume and we are going to go into the volume right here and do the sub settings and under record file access time we'll just say never and that's all you have to do now you'll never have to worry about that and btrfs will be more performant when it comes to snapshots for small file systems don't worry about it if you find a use for it but for large businesses who have thousands and thousands of files being opened every single day it can actually be a very big performance hit by having to have all these extra complex snapshots that are actually completely useless because the file was not changed it was just the access time was changed but i recommend turning that off for most people alright and so now on to snapshots so the first thing you're going to notice is this pane called snapshots this is where the vast majority of regular users are going to spend all their time snapshots have a few different schedules i'm going to talk about here but the vast majority of people are going to focus on shared folder snapshots there's also one for people who are using iscsi you can also snapshot those but for the vast majority people you're going to be using shared folders and you pretty much should enable snapshots on every single shared folder in my opinion except for like one case that i know of the only case that i really know of that you should not have snapshots enabled for is if you have a security camera system and you are absolutely on kind of the performance brink of your nas so if your disk utilization is over like 40 just standard recording btrfs snapshots might push it over the edge having to snapshot all those changes every single time and so i might not use snapshots there maybe you take them once a day and you might get a bit of a performance hit there but that's kind of the only use case where i see not taking snapshots as being useful and so instead the question you should be asking yourself is one how often should i be using snapshots and two how long should i keep snapshots so let's just go ahead and open up a random new shared folder we'll open up this photo one right here and we're going to set up snapshot settings on them by the way really useful feature if you shift select you can edit multiple shared folder sections all at the exact same time super useful but we're just going to edit this one called photo so we're just going to go into settings and we can see i've not yet enabled the snapshot schedule here and so we can enable it and now we get to choose what days it runs and how often it runs so for people who are just using it like photos right here photos if for whatever reason happened and i lost the past seven hours of edits to photos because something crucial happened that would not be the end of the world for me so daily probably makes sense you can also say i only want to run it on certain times but for most people daily or maybe every four hours is quite good if you are a business and you really need up to date you can do snapshots every single five minutes now i do recommend having some pretty performant discs for this and a more performant model but the ability to take a snapshot every single five minutes and restore from for a business can be very useful especially if you're replicating those snapshots with an a b setup it's very useful but you've got a ton of options here just know if you're doing under an hour make sure you've got the performance to handle that because i have seen it kind of stall out and you don't want it causing stall out if you're never going to use snapshots that granularity so to keep things simple we'll just go ahead and take a snapshot every single day all right and so that answers the very first question how often should you use snapshots it really comes down to how much granularity you need for the restore options the next question is how long should you keep them this is by far the most important question essentially what you're answering here is from the moment delete a file so the moment you to space back how long should that be you can kind of think it like a recycling bin that automatically empties itself after 30 days so what i often like to do is set up a policy that is keep the last snapshot of the hour for 24 hours makes sense and then we'll just do dailies for the past seven days then we'll we'll say we have a copy of the file system for the past four weeks pretty much if i have to restore something from over a week i'm not going to get crazy great granularity but it's been a while so i probably don't need that so this is probably good for most people because it's pretty likely that from the moment there's an issue it's going to be figured out within probably seven days and then the four weeks there is just useful in case anything does happen now if you're never deleting stuff and you really just want to make sure that if anything does happen you've got a lot of points to back up from you can increase this to like eight weeks and if you're never really deleting stuff or changing things and you're just kind of adding stuff in think like a photo archive this is really not going to take up much space at all because you're not changing files you're only adding files and snapshots only hold on to files that have been changed or deleted and so eight weeks for a file system that's pretty much only adding in data is probably not going to take up much storage at all then the last thing down here is snapshots automatically keep a certain number of snapshots before applying these rules that way if for whatever reason it stops taking snapshots or anything like that and there's a glitch you know you at least have some snapshots and so in this case it will only remove snapshots if there's at least five snapshots accessible and then after that it'll go through and look at these rules and try to find snapshots that exceed these rules and so maybe you have two snapshots from three days ago and so if you look down here we can see that okay well it's been past one day so i don't need to keep it it's been past 24 hours so i don't need to keep it from this rule i already have one snapshot from that day so i don't need this rule and so there it's like okay it has not been required from all these rules it is now safe to remove and so that's how it works and so if you look actually right here this second setting right here is redundant because 24 hours is one day and therefore automatically all my snapshots are going to be kept for one day and so these two kind of are redundant here so you you can add extra granularity here you're probably only custom using this one is if you're using those advanced ones that are under one hour and so that is how snapshots work i will warn you if you keep a snapshot for a year you're pretty much never going to get spaceback from deleted files now if that's your setup more power to you you just know you've got them but i very rarely ever enabled these two unless there's a very small file system that people just want to make sure they've got a lot of archive so it's almost like a hey this client's totally billed out we're good i'm fine deleting it but if a year from now i hear from them and they really want me and it might be nice if i could possibly restore from that you shouldn't really rely on these but as a hey can't hurt you can i still recommend probably never use anything over a month i would really just focus on weekly at that point that's at least my opinion all right so now we've got the rules figured out so now let's look at some advanced configuration and by far the most useful one of these is going to be make snapshot visible now note this setting is not available if you've encrypted the shared folder unfortunately but makes snapshot visible is so cool and so i've been in big company before and it sucks trying to deal with it to get an old copy of a file the majority of the time even though there's almost certainly a backup of the file system that's probably easy for it to access it's probably easier for me not to deal with it and instead just remake the document because it's such a pain you've got to set up a ticket everything just to get back a couple hours work it's probably going to take you more time in dealing with somebody else than it would just redo the work making snapshots visible can completely remove that so by making snapshots visible it creates a read only folder called pound snapshots hashtag snapshots in the shared folder and i'm going to show that here in a minute but what that allows you to do is that allows all of your regular users to browse the old copies of files the old snapshots and grab the documents themselves the beauty of them is their read-only so there's nothing they can do to remove these files now the one thing to think about is if somebody deletes sensitive data it's not actually deleted because it's still in snapshots and so if that ever did happen you would want to make sure that either the snapshots were removed or if they really should not be removed maybe you make the snapshot folder not visible anymore that is one thing to think about if you do not want your employees to have a history of all the files on the file system all right and so now let's show this in action i'm going to be using this family shared folder right here first thing is we'll look at the snapshot list and we can see we've got a few snapshots already here and so now i've just connected it over here using smb and so as you can see right here we've got the recycling bin but there's no snapshot folder so now let's just go in and enable that under settings advanced make snapshot visible and so now right here we've got the snapshot folder so we can see out all the different versions of this file system exactly how they work at these times and so now let's kind of see this in action because right now this is just my test bench so nothing's changed on it in a while so now let's say that we want to add this new folder very important data and we're going to go in and add in a new text edit new document i don't know there we go very important we've got a client meeting at noon we've got to make sure to make it but now let's say something happens so we're just going to demo how this works so we're just going to go ahead and take a snapshot by the way this lock command right here means that it will not be removed automatically by snapshots so this is very useful if you want to make sure you've got an exact copy of the file system before you make some major changes just make sure to unlock it unless you want that space to literally always be there all right so we just took a snapshot more likely than not it's just an automatic snapshot that happens so we've got the snapshot now all right well now let's say this gets somehow corrupted right who knows what happens maybe somebody deletes it who knows and we don't know where it is we can just go in as a regular user i'm currently logged in as a regular user and we can just open up the snapshot folder right well we'll just go to the one today and let's open up secret stuff and see this is the exact file as it was when it was taken even better let's try to edit it so we just changed it some we can see that that file is read only all these snapshots are read only and so that means you don't have to worry about employees messing up the backups not backups but the redundant but the copies of your data because they can't edit them they can only read them so we will just have to revert it and so now we say okay we know that this is the version of the file we actually want all we have to do is go ahead and drag it from the snapshot back into the future we're going to replace it and we've just copied and pasted it in there and so now it's just like it was never gone it is that easy to use these things and it is so valuable for everything you need it is so nice for it never to have to get involved and just be able to go back to previous versions of files all right and so now let's say that something crucial happened let's say that we got attacked somebody got ransomware and one of the computers got encrypted and so let's say they i don't know so say they took all of our data and encrypted it all right so the one thing is this is where my space reports are so i can't actually edit this file as a user but hey we've been ransomwared oh no so now instead of forcing us to either restore from a backup which we might not have you should definitely back up your stuff but a lot of people don't or pay for the ransomware instead what we're able to do is just roll back the file system now this is going to be something you should only do in the event of true life okay i know i just need to blow away everything you've got kind of two options here so what you can do is you can go into the recovery menu and we can recover it and we'll say that this is the last good snapshot we probably should browse to it first so we'll check it out make sure everything's where we want it everything's good and then what we're going to do is we can either clone with a new name or restore to the snapshot restore to the snapshot is very decisive it blows away whatever is currently there and now boom on top of that is the current snapshot if you've been ransomware to something and you know you've got a good copy of your data this is okay to do but what is safer to do is clone with a new name so cloning with a new name lets you kind of put it in parallel and that way you don't blow away the current snapshot but we know for a fact that we are good so we're just going to blow this thing away and we're going to do a total restore now the nice thing they do is they have this right here where you take a snapshot before restoring unless you're like really running low on data or something you should definitely do that just in case there's something you missed you don't want to completely blow this thing away and then not have it if you ever needed it and then if you've got some very specific shared folder permissions that's pretty much the only thing here you can also restore that up to you probably should do both we're just going to go ahead and do it all right and so now let's just go ahead and open up that folder again and immediately we can see this is exactly how the folder was before we got ransomware now the other thing is we can go in and we can still see that ransomware file if we ever need it for whatever reason who knows but we are safe on that and that is how easy snapshots are so those are the really big hitters now let's talk about a couple of things that are useful for kind of figuring out the space side of things so snapshots can take up a lot of space looking at hyper backup vault that will take up a lot of space with snapshots i would recommend taking weekly snapshots for that for however long you'd like to same thing with time machine those are things that change very small files but tons of them all over and so when you're taking snapshots it can kind of take up a lot of space and so i recommend keeping only like weekly versions of those for most people so anything like that that's constantly changing slight files and that you probably don't need crazy granularity for you should really look at having like weekly snapshots for and maybe only keeping them for like four weeks all right and so now let's talk about how to get space back immediately that's the nice thing about this is you know you can always get your space back whenever you need it so say you know okay i've had to clean out my nas because i've got only like a terabyte of space left we're running low and i know i know the file system is good i know i don't need that date anymore i need the space though we can just go into family snapshots list select them all remember this is going to blow away all previous versions of files you're still going to have all of your files in there but you're not going to have the snapshots of them and remove and this will instantly you can see up here we are now getting our space back this is running space reclamation and so you can immediately get space back from snapshots should you ever need to another thing you can do is say you don't know where all your space is going you can go in here and calculate the size of snapshots so it will go through and it will look at all the previous versions of files and it will tell you i will say for massive file systems and a lot of snapshots this can take hours but it will very quickly show you hey this is how much space these snapshots are using and so if you're trying to get space back and you're like okay where can i just grab space back this is very useful alright and so now one other thing i did want to mention is say you stop taking snapshots on a folder that does not mean the snapshots are removed so go into recovery and this will show you where all of your snapchats are so say you stopped taking snapshots a couple of months ago because this folder you just don't care about that much it's constantly changing it's just taking up a lot of data whatever reason but you stopped the snapshot task you never deleted the old snapshots so this is where you will see every single folder that has snapshots in it and you can recover from them there alright well that's pretty much all i've got for you snapshots are a tool that every single btrfs nas should be using because they can save you so much hassle and headache and it just gives you peace of mind and knowing that if you need to you can go back from stupid changes it is such a nice thing to have and they just run the background beautifully go and leave any other tutorials you like see me make in the comments below and if you'd like to hire me for a project i've got a link for that in description as well alright have a going bye [Music] you
Info
Channel: SpaceRex
Views: 48,298
Rating: undefined out of 5
Keywords:
Id: P-9osuSdGGI
Channel Id: undefined
Length: 30min 18sec (1818 seconds)
Published: Wed Jul 20 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.