 Hi there guys, welcome back to DanielRosal.tech on YouTube, Medium and at the website DanielRosal.tech or at my personal website DanielRosal.co.il So I have just been QA'ing the script testing it. I'm almost there. There's always an awkward process of QA'ing stuff. I specifically the I didn't have the bash operator at the start of in my Synology and that was creating problems. But basically what this is in the last video I went through it in depth and I'm just going to do this more quick a quicker explanation just to show exactly what this does. This is a bash, just a simple bash script I've written up in order to back up using the arcing command line interface my shared hosting. Now shared hosting is a tricky one for backups. If you have a shared hosting, shared hosting is the entry level sort of hosting for anyone that isn't familiar stuff like GoDaddy. Now GoDaddy offers VPS and almost every shared host does offer VPS nowadays but it's the entry level cheapest form of web hosting that most people that just have one relatively low traffic website will purchase shared hosting and then move upwards. It's because you know there's a lot of great backup solutions for for instance AWS but not everybody that isn't a professional developer is going to be it would be grossly overkill to run a little portfolio website or a little blog on AWS you know unless it was super high traffic and unless you just loved AWS and had those had those skills and I use AWS but I can't see a reason at the moment to to migrate my infrastructure there. So for shared hosting and reseller hosting which also works on usually a C panel basis reseller just has a thing called WHM which is like the mother C panel and you give your typically your reseller clients access to the children's C panel but this is a means it's a script I've made for backing up. Now the problem with the problem with RSync is that when you're in shared hosting you have access to typically from the root of the server home forward slash foo foo of course stands for your username and c panels so you're basically caged you can go anywhere above this but you can't go anywhere below this in the server and what you have below you in the server is a directory called var mysql and that's in shared hosting where the mysql now you don't want to back up mysql databases just by capturing the raw databases you want to use the actual export format and but for this reason it is it's you can simply back up like you would in a VPS bike going from the root of the server and then being smart about what you grab so what I have the system I have devised in the last week to back this stuff onto my Synology NAS is now this is basically modified version for the benefit of someone using it so when I was queuing this I wanted as much verbosity as possible so I used you can see you can daisy chain three v's for verbosity so RSync minus a is archive a is archive r is recursive z and I'm looking I'm cheating I have the RSync man page in my other screen here minus z can also be used by typing minus minus compress I call these minuses some people call them tax I'm watching a linux academy of course where the guy called some tax I don't know why that is but anyway I call these minus so minus z or minus minus compress now this minus e and then in single quotation marks ssh minus p poor number that's if you're using a weird ssh port um the standard ssh port is 22 of course but nowadays a lot of hosts well I don't know actually if a lot of hosts but some shared hosts if they give you ssh access to your hosting they insist that you use a weird non-standard port such as one two three four five typically it's not one one two three four five I've just changed this a little bit here um so that's what that is so if you're you if you're not using 422 this is how you you connect via a non-standard ssh port tack tack delete slash minus minus delete is deletions at source so when I'm creating these backups I want to be capturing what I delete so if I'm in the shared hosting and I have um you know if I can just zoom in a bit over here if I have home uh me public html wp content this is a wordpress for instance uploads etc etc and I delete one dot pdf I want that to delete on the target the targets where I'm backing up to my computer or my nas so that's what minus minus delete does um it captures deletions progress is another thing to show you I just went uh whole hog on adding everything that could possibly show me more info but what was going on because you do you do sometimes get this rsync can hang hang on it'll say rsync um something like rsync waiting waiting on incremental file list and if you get a message like this rsync is checking the source to see what's changed since the last ran and if it's a big file system that can take a while um so I was when I was qing this I just wanted to know exactly what was going on and when I added these three two extra most people add one verbosity when you can add three I don't know if you can add four I think I read three was a limit but when I added three it was really showing me exactly what was happening we're checking everything on the source and uh what's new has been moved then you have your username this is your cpanel user okay not you're necessarily the username used to log in um and then the ip address of your server then a colon and then it's the relative path sorry the absolute path from the root from the root of the server very important not just from the bit you can see which uh it might look different in file manager and then you have and this is also important this is also where I went wrong in my initial test you want that trailing slash if you do not have the trailing slash public html trailing slash in your backup directory you will let's say I wanted to back up here so I want to have it like this I want to have a trailing slash that means everything here is going to go here if I have a like public you know rsync um operators public home cpanel user public html if I have it like this what I will end up with is public html building itself a folder um on the target and I don't want that I wanted everything specifically I actually have it like this um my size boom um so I didn't want my size public html boom so you can you just kind of learn these things as you play around with the command line interface in the scripts so that's another thing just to bring to your attention um and that is essentially it now for the my sql I have a cron job running on the server which um I created this folder and just another another thing to point out is as I said in the last video do not put this do not put this in public html because then it will be exposed to the internet anything in public html or above in a shared hosting environment is exposed to the internet so I created this folder called backup and I created a cron job what which was running I'm just going to zoom in again it was running my sql dump um I forgot the parameter and it just said I told it which database my wpwpdb.sql and I said please put it in home my cpanel user backup and again training slash so then this creates a database here my wp backup.sql and if you don't know what your um if you forget what your wordpress um I'm just assuming you're backing up wordpress if you forget what your wordpress my sql database is called you can check in wp config and you will get there the my sql db the my sql user and the my sql password so all your credentials will be visible in plain text in wp config so make sure you have the right permissions there do not whatever you do do not whatever you do something like this um so that is that so I run that is a cron job on the server and that spits out the my sql database here and then in another line on that which I've uh written my sql uh backup I then move the database and on my this is and this is the Synology so you can see um in Synology you go like this the actual path is forward slash volume one forward slash the shared volume name forward slash and I created all these directories myself manually forward slash my site one forward slash db forward slash my site one so the files go in this guy this this level the my sql goes in this guy website two and you can have website three website four etc repeat the process so this is my Synology I've just logged in over here and uh you can see that I have a couple of test scripts for testing purposes and um then I just need to run this guy and let's just see what happens this is basically the same script with uh details replaced and that's it so basically that's what you need to do in order to get it to run final step in the process for me was putting this on to a volume in the Synology NAS I created a volume just called scripts with capital s put in my bash script that I edited down my computer just did a drag and drop thing in a file station and um then I basically set it running with bash prefix do it put that on a schedule and uh so far it's good I um don't take this one center on details only when the script terminates because I wanted to just make sure that it was running so I left that unticked and every time this runs at midnight I get a little email notification saying that the script has run and all the changes I've made during that day in my in the couple of websites I'm backing up um are pulled down the new my sql databases are pulled down and they overwrite the existing ones and unless I am mistaken mistaken something I'm getting some sort of a daily incremental backup copy of my website and I do still take the full backups because I trust those more that's using the c-panel native interface and I export those but just to always have a very fresh copy and I'm going to build out a weekly folder as well just to sync those two as I described earlier just that I've won that lags a little bit further back in time but this basically reassures me that if I do something like make a new WordPress post or add a new pdf to my site for backup purposes that that's all going to be captured pretty quickly um I don't think I think a day is fine I wouldn't want to be running this more often than that and putting putting pressure on my web hosting resources but of course you can do whatever you whatever you like according to the type of infrastructure you have in the cloud thanks for watching guys and if anyone ever wants to get in touch my website is at danielrosil.co.il have a great day