Scheduled backup of your user folder to a network location

datalossThe blurb

One can never have enough backups. Backups are important and you shouldn’t let one day pass without having them.

Hard drives fail, data gets corrupted, devices get lost or stolen and whether it’s some important files, your vacation photos, or your entire library of saved passwords (you shouldn’t have such a thing in the first place, but not everyone follows the rules), one day you will sit in a corner and cry after what you’ve lost.

Unless you have backups. Backups let you restore your precious lost data in a matter of seconds / minutes / hours (/ days?)

I recommend creating system-wide backups periodically – at least monthly. System-wide backups mean either the entire system partition or the entire hard disk (depending on the amount of data and its importance).

Having such a backup will allow you to get back to work in hours after a critical failure without having to start everything from scratch with an operating system install.

But that bit of data which is more precious and/or is frequently changed/updated/replaced, you’d need a more often backup schedule.

This can be easily achieved with an archiver (like 7Zip)

The technical bit

Create a file named backup.bat. You can place it anywhere, but just for consistency, I’d suggest placing it in C:\Users

Extract and place the 7za.exe file (7Zip CLI binary) in either one of your system folders (C:\Windows, C:\Windows\System32) or in the same folder as the backup.bat file.

Paste the following contents into backup.bat:

Modify the remote server name and username to fit your conditions. You could also adapt or duplicate the paths to include additional folders. Make sure the remote location is accessible and writeable.

If you want to include the time in the archive filename as well, change the specific line to

To further explain the command line:

  • a – instructs 7Zip to add files to archive
  • -ssw – include files that are currently open by another program
  • -xr!*.vhd – exclude Virtual PC hard disk files (there are usually very large and you should probably back them up separately)
  • -xr!*temp* – exclude all temp(orary) files and folders
  • -xr!*cache* – exclude all cache(d) files and folders (caches mean tones of small files)

Next it’s time to create a scheduled task for this batch file. Open up Task Scheduler and create a new task (Action > Create Task).

task

Set it to run according to your needs.

Leave a Reply