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
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.
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):


