 Hello there, welcome back to Daniel's Tech World on YouTube, Medium and at DanielRoseville.tech. So for today's video I wanted to demonstrate a way to back up a shared hosting account with R-Sync. Now I'm going to explain all the stuff that means in a second. R-Sync is really a Linux tool. There is something like it for Windows, but basically this video is intended for people running some Linux distribution as their operating system. Now we showed in a previous video on this YouTube channel how to take full backups of your web hosting. In C-Panel there is a functionality called backup. Now C-Panel is typically the way you'll manage your website. If you use shared hosting or if you use resetter hosting, if you have VPS you'll have root access to the folder and that will make from a backup perspective in terms of taking incremental and R-Sync backups that will make life a whole lot easier for you. This is just kind of a sort of ugly but effective work around that I've developed because I'm at the kind of intermediate stage of growth for this site here between resetter shared hosting and VPS. So the deficiency of taking a full backup, which is what we looked at last time, which is the C-Panel functionality as I said. It gives a very unified format which is useful for transporting stuff between different hosting providers. So for instance if you go through that full backup it will create a, as we saw in that video and I'll put the link in the description, it gives a nice tar-gz archive and if you go and unpack that archive you'll see that it's got a very specific format and it's got everything from the files, to the MySQL, to the cron jobs, to the email filters. It's a standardized format for portability between web posts. So what we're going to be doing is in this case it's a more bare-bone approach. Now I would actually recommend that you do both. That's actually why I've implemented this. I always do these manual full account backups and the websites I really care about which there's only actually two of them. I'll try to do them. My plan is to do them once a month. I would say typically once every three months. But the problem with them is that because they're backing up absolutely everything every single time they run, if you have a big website that can easily be a five, six, ten gigabyte archive of data and we've talked, I've talked in every video I've done so far on YouTube about the importance of three to one backups, primary plus two data sources, two different storage media, one of them off site. Now the problem with running a full backup every single time you want to back up your web hosting and you're backing up your web hosting because nobody should have 100% trust in their host and even if there is a little incremental backup utility in your shared host it's a really good idea to keep your own copies of your data. So moving those full images off site every time is really heavy work especially if you've just got a regular home internet connection that six or a ten megabyte upload could take all night. Now I've recently set up an NAS on the network so that makes it a little bit easier but you know it's still a lot of data and it's inefficient. So my plan is to have this R sync job running. In addition to that I can feel confident that there's a daily copy being taken that will be the first way to get anything back, a daily copy I own and in the event I truly the nuclear option ever occurs I'll have that hard full backup as well that'll be at most one month behind the present. So given that we don't have root access in a shared environment there's two things that I'm going to focus on getting out of the host and putting in our own repository. What I'm going to do is just build a little folder on my desktop here, separate that into files and the database and we'll run an R sync command to grab each and we'll use one WordPress plugin. Now if you go to your shared hosting environment you will find I'm downloading from the WordPress root folder I'm not doing public HTML I'm not doing the root folder there's a lot of stuff there that if it's just you know if your objective here is just to capture a snapshot one day old constantly updated via R sync of data you don't need to get all that clutter in the user folder so just go for the WordPress root folder as you can see this WordPress installation is very very small I just threw this up in a second at Daniel, demo.DanielRosal.tech so it's on the root folder of a sub-domain so that's the one I'm going to be backing up. So the command the first command we're going to need for this is we're going to be using R sync to bring down stuff from the server so as you can see what I've done here is I've added this SSH minus P I just pay attention to the syntax because this is if your host uses a non-standard SSH port now my if you have shared hosting I'm not sure that they all even allow SSH access mine does but they give me this weird port now it's not one two three four five I've just swapped that in but to take take a look at the command so you've got R sync minus R AR VZ V is verbosity among others now there is another minus e then setting the connection port if it's not standard I like this one as well as I'm just going to add it two ones to talk about actually now if you're doing if you're running this from a crontab and that's my ultimate aim here from a bash script that you're just going to be running while you're not there you don't need this little progress bar but even with the verbosity parameter on I don't find our thing tell to you enough it's particularly when you're trying to make just do a first runner to to make sure it's running okay I like this progress thing gives you more info it shows each file and little kind of you know graphical depiction of that progress and lead so if you are keeping track of your hosting file bay on your local then you'll for sure want to be syncing the license from source to targets or source here is our remote server and our target is our local hosts so that's the start part of the command now this is going to be your equals your cPanel user I mean this I presume is kind of obvious to most people watching this video but just my user before your the IP address is your cPanel user it's not the username you you use to sign into your shared hosting account whether your host is godaddy or whatever if you log into cPanel you should see somewhere in the site bar watch your username your username on the server is now shared hosting you're going to be caged your root is going to be forward slash home forward slash something on a VPS server you're going to have root access so that's why this command starts with forward slash home forward slash my user and then it's the directory from the root so I would actually go for this as I said the WordPress here was in the root of of of the public underscore HTML so you have this folder this is the the home folder and then there's public HTML and if you have WordPress sitting at the root of you know your domain your domain com then it's just gonna be sitting at this directory relative to the server root and you can't you can't get any lower than this but of course home is one layer above the root of the server right typically in a Linux server not typically always forward slash home that's where the home account sorry so you don't there's a level you're not seeing there which I'm just denoting by those couple of dots but if you're in VPS then you don't need this tutorial because you don't need to separate out the process of grabbing the files and my SQL databases in this manner so we have our cPanel user name we have the public IP of our server and again you'll find this in your cPanel on the site and probably somewhere else near hosting one colon and then the root home my user public and just end so that you grab everything from that point forwards and then I would just as I said I created a folder here on my desktop called restore files and I'm gonna put that into files and DB DB of course being the my SQL database now that's basically the syntax here for what you need now you can do you can do is that what you want I would you could put that into a cron job you could execute this and if you have a Synology NAS which is my new favorite toy there's a thing in there called task scheduler and it's basically like cron job engine now of course before you go about using our sync from your local machine to connect with a remote server you need to go ahead and make sure that you can SSH into that server typically that will involve you know generating an SSH key pair and importing that into your server so that you're able to authenticate so that's kind of a prerequisite to this whole process that I jumped over but that is indeed the first step so we're now basically ready to pull down our files from the server so I'm just gonna go ahead using our sink I'm just gonna go ahead and do that okay so as you can see the our sync job why that was quick our sink is really really good now I'm not sure if it's quicker than FTP as a protocol that's important to remember that our sink is its own protocol I think it is I'm sure that can be found out easily online that was literally three seconds and it's incredible to think that that was actually a sync all the way from a remote server that was not a local area network sync the alternative methodology which I'm not going to show in this video because I think it's a little bit easier to do it this way the problem really is remember as I said previously when you're in a shared hosting environment your root folder is this so you have all the files in this but you are not getting down to clearly you can't access for example var and that's where the my SQL databases are stored in the server so you have to find some other way to get the my SQL databases out if you want to keep a you know daily backup of them one option to use here is you can use my SQL dump which is a my SQL export utility that's what I would do is set up cron job on hosting server and that would be to export my my SQL dump WordPress database to and then relative to the server that would be let's say backups so then the path that you would want for your arcing job on the remote side would be you know user user at hosting IP as we did but it would be forward slash home user backup or you know you could do backup my SQL and that would be the past then there and then you know just back up to your local home backups or this could be an NAS as I said home backups hosting DB so that this is a two-part one setup one is one is set of cron job on the hosting server to do your daily my SQL dump of the WordPress database and put it somewhere that you can't access on the folder and as I said this backup my SQL is relative to your shared root but it's an actual fact the real the real full link to that directory is actually from the actual root of the server at home your username backup my SQL so that's a one-two approach to is run our sync from hosting server to local and as I always say or and he asks they think it makes a lot more sense to run these jobs off a server or an NES if you have on at your disposal so that's the alternative approach bit more you know a couple more cron jobs and commands required but this is a sort of easier way so with the easier approach go into the WordPress plugin repositories and look for database my SQL backup actually should find it pretty quickly now there may be there's a lot of WordPress backup plugins as you can see here I won't comment about these because I've tried I've tried them all I find them actually quite buggy when you're backing up a large multi-site environment and I'm not sure I've seen one that separates out you know that's just designed to get the database and not the file directory so this is what I was looking for a WP database backup but you can see it's relatively well maintained update or sorry relatively frequently updated one month ago now this can do backups to remote sources you can go straight to a an S3 bucket you can go to Dropbox you can go to Google Drive there's a few options so once that's installed it's actually under tools I was looking for it in settings for a while before and it's not there tools you can see the very bottom option here is WP database backup now if you look into your settings over here there's a couple of things I would change maximum local backups because you don't want to be taking one of these if you're running it daily and you know you'll wind up with eventually gigabyte to stuff on the server so firstly I would just keep that to keep that to two or something of that nature I mean for a tiny side of this size that nothing really on it there's they're gonna wave very very very much almost nothing but for for the bigger ones they do so sorry destination is where you'll find the remotes and as he said you have a few cloud storages you have FTP slash SFTP but there is this option here for enabling local backups and you can put so I'm gonna enable this and remember this is not the this is the real the real guy so I would put in here something like if you're if you see panel account was demo account and we said I recommend creating backups at the root the important thing is just not to put stuff that's where you put it now the important thing here is just not to put it anywhere within public HTML or below public HTML so I created my backup folders home user backups and that's where I'm putting the just for the purpose of keeping stuff clear it probably better to call it my SQL those literally at the root level of my shared hosting environment you don't want to put anything here as I said because anything will be publicly accessible so that's the path make sure it exists firstly before you go ahead and do that and then you can go and create your backups then you just click on create new database backup now if you have it on schedule it will start creating these the first sign just for this demo I manually ran it so this is really really minuscule it's as you can see 46 kilobytes in size so now I'm gonna show you the next our sync stage so our second our sync command is gonna look essentially like this our sync our usual parameters again the weird port in my case if you have a standard port 22 connection to your hosting you don't need that your username on the cPanel your public IP for your server as I said put it at home demo backups my SQL keep everything separated out and in this restore folder that I'm building on my desktop here I actually called it files and let me just quickly change that files and I'm gonna run that command and pull down the backup that we just took with the WordPress plugin case that job our sync job the second one just finished running we can see on my restore folder that I've created my desktop here I have two folders one contains my SQL and the my SQL database weighing the same the same amount as the WordPress plugin took it at about 600 kilobits I didn't need I should have just changed the syntax a little bit here and likewise for the files but they are also there the WordPress files that's a quick way of making sure that in a in a shared hosting environment where you don't have that root access that you can just make sure and again the point of all this of all this demo and setting up these arcing commands was that you can put them running and you know put those into wrap those into a nice bass script put that as a cron job and keep it running one times a day and you'll just pull down and because there's only two there's only two my SQL databases back up being stored on the server it would actually be a good idea to add the minus minus delete flag as well to just to get the source deletions for the my SQL database because otherwise as he said you'll end up with quite a lot of them thank you for watching hope this video has been helpful for any any anybody would like to get in touch my website is danielrosil.co.al thanks for watching