How to Backup your PC with a Simple Batch File
Hello, everybody, this is Halla with Information Leak. I'm doing a tutorial for gentleman called BL_Walla. He was asking how to backup files. I suggest that using a batch file to do so and automating that process. He explained he didn’t know how therefore I'm making a video for him. So BL_Walla this is for you.
The first thing we’re going to do is determine what files we’re going to backup or directories or files on the directories and where they're going to backup to. So for this particular video I should say I'm going to use this folder, the stinky folder that has just a couple of bookmarks in it and a text document that has nothing in it. It’s just nothing.
So what we’re going to do is we’re going to create this batch file first. Therefore open up notepad and we will write this, @echo off, not necessary but why not. Now some people specify stuff. I like to set things so I don’t have to type them over and over again. In this particular case, I might as well do it even though setting a drive in this particular instance is more of typing the normal. I might as well show you how to do it anyway. First thing you do is set the drive. The drive is where you're going to backup to. In this case it’s going to be the F Drive which the F Drive is my west and digital backup drive.
Okay, so that’s that and then was going to set something else. Set it back up and backup it’s just going to equal and X copy command and we’ll add some switches. Now let's go over the switches and please note the order I do them in, okay. It’s kind of important. First were going to set the S-Switch. These copies directories and some directories but doesn’t copy empty ones, okay. So you're going to copy everything but empty directories and folders and subfolders. Then we do the C-Switch that continues. Now it’s going to it’s going to continue to try to do what it’s doing regardless if there is an error or not is going to try to do it so right off the back. The first thing we do in this copying directories and subdirectories and then forcing it to continue.
Then at the same time do a D-Switch which is a date. You can add a date to this through a format like months, day here like that if you wanted to, but in this particular instance I'm not going to do that. Now what date is going to do is anything newer it will save, anything older it will ignore at the same age. So basically, if it finds add file, even if it is in the same file if it’s a newer it will save it, if its not it will not. This way as you update your folders and files it saves them.
We’ll go with an E next and E is like S and that it copies directories and so directories. But this one this time it copies even empty ones so it does both. It’s kind of like a redundancy thing, okay. After that were going to do H that’s to make sure that’s hidden and system file are copied and after that were going to do I. Now I is kind of weird. I basically means one and out assumed a destination as a directory, so that’s means if it can’t find the destination they're talking about assume that that destination is at directory and considering that directory is our destinations that would make sense. Again it’s just a little bit of redundancy. It can save you some headaches.
If that will do R, which is read only files make sure those go over and then after that we’ll do a Y switch which means yes, so when the thing says, “Oh, this file already exist are you sure you want to over write it” that switch will automatically select yes. Okay, now at this point you know you could write something if you want it, @echo off, echo backing off or something like that I don’t know. Backing off now, you don’t have to really do that. Okay, so now let's back to sucker up. First thing were going to do is call it backup just like that one, backup actually. I didn’t want to do it like that, I want to do it like this. Okay, percentage backup percentage, there we go. Now were going to tell it what to backup considering these three things are on my desktop. I'm just going to go straight to user profile instead of writing out the entire thing. It’s a lot easier that way.
Like that, okay, so now it’s within and to the desktop and thinkgeek was the name of this particular folder that I will be backing up and where are we going to put that. Well, we’re going to put that in my drive which is at the F. I could just put F colon equals but I already set it to drive just showing you how to do it so I might as well do it like that. There you go and now I would just set to drive that’s fine so that will work, so at this point, you can even add a pause if you really wanted to. Basically what that will say is hit any key to continue which is handy because you'll know that it did it but later on—well I’ll show you in a minute. So now you save this as whatever dot bat. So well call it backup.bat for example.
Okay, so here’s backup.bat just showed up and if we look at the F again, F Drive refresh you’ll see that nothing exist. So hopefully when I run this a thinkgeek folder containing that information to show up, let's take a look, I'm backing up now, press any key to continue, I press any key and it ends. We go back to the book and there it is. It didn’t create the directory though, no big deal.
So at this point were going to have it make sure it creates the directory because that can be very annoying. So for right now let's get rid of this stuff. I just save it to that root prior, no big deal. So if we go back to the batch file and we select. It’ll fall to the name. It doesn’t have to be the same as the other one for just to show that I’ll add up one to the end of it thinkgeek1. Once we save that and run it, it should create a folder named thinkgeek1 in the F drive, there it is and it should contain all those things which as you can see the same as the ones that we backed up here.
So interesting, now let's add to this. What we’ll do is we’ll take that thinkgeek1 on the desktop on the top of this new text document into it. I don’t believe there is anything in this text document, no there is not. So what we’ll do is we’ll just put a number one in it for now and then save it and we’ll close it.
Okay, so now there is something in there new, this is the backup drive. It does not contain that because it didn’t contain it until just now. Now we run this again, as you can see it only found one file we take a look. Take a look at the drive in that folder it should be the new text document and if we open it up it shows one very neat. Okay so let's close this again, open up the folder on a desktop locally and let's update this.
One, two, three we've just changed our document and save. Close it were on the backup its doing it now, found one new file, press any key to continue which I do. Open up the backup drive, open up the folder find the new document, open it up and make sure that it took and it did, so there you have it. Quiet simply, the way to backup your files to whatever location you like, obviously you can just continue adding the strings and drives and such as you see it fit. Let's see how long this video is right now and if I have time I’ll move on and show you how to automate this. It turns out I don’t have time but you could just go and set it in the automated task and windows. This is Haller from information leak signing off until next time copy system.
Transcription by:
Scribe4you Transcription Services