Backup your data locally

In a world where we have so many cloud solutions for backup (like OneDrive, DropBox, Google Drive, etc), there might be still people like me who like to keep their personal files somewhere safe offline. Now, i usually keep my important files on a network attached storage, but for this example we will have a look on how to backup your data on a different partition. There aren’t many differences anyway.

First, we need to know what we are backing up, and in my case I want to backup my desktop everyday. I have a bad habit of keeping everything on the desktop, and where everything becomes cluttered I start deleting like crazy, and many times I found myself deleting stuff that I didn’t want deleted.

Now that we have a desired folder we want to backup, is time to start creating a script. I will place the code for VBScript as well as PowerShell.

VBScript

On Error Resume Next
Set WSHShell = CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
UserProfile = WSHShell.ExpandEnvironmentStrings( "%USERPROFILE%" )

FSO.CopyFolder UserProfile & "\Desktop", "D:\Desktop Backup", true

PowerShell

$CopyLocation = $env:USERPROFILE + "\Desktop"

$CopyToLocation = "D:\Desktop Backup"

Copy-Item -Path $CopyLocation -Destination $CopyToLocation -PassThru –Recurse -Force
Now that we have the script created, we need to do one last final thing, and that is to create a Task Schedule. Open the Start Menu and search for Task Scheduler and open it up.
Once the Task Scheduler opens up, expand the Task Scheduler Library from the left side. Now right-click the Task Scheduler Library and select Create Basic Task.
Type a name and description of the task and click Next:
Select when the task should start. I want to backup my Desktop daily so I’m going to leave it as default and click Next:
Next, select the desired time when you want the backup to occur. In my case I want it to happen everyday at around 2AM.
As an Action we are going to select Start a program and click Next.
In this widow we will have different options. If you went with the VBScript, you probably saved it somewhere on the machine. In my case i saved mine as backup.vbs on the desktop. In this case, we need to configure the program as follows:
If you went with the PowerShell method and saved the script somewhere on the desktop as backup.ps1, then the program should be configured like this (keep in mind that you need to specifiy an explicit path to the .ps1 script, not like I did in the image):
The final window just shows the summary of what we previously configured. Click Finish.
And that is it. Now everyday, my desktop will be backed up on my D:\ partition. You can change the scripts to copy your important data to a network attached storage (NAS), a different machine on your network, or an external hard drive. The possibilities are limitless.

Sharing is caring!

Leave a comment

Your email address will not be published. Required fields are marked *

12 − 1 =