Simple file backup

If you are like me and like plenty of backups for small files that are used day to day you don’t need a high end over complicated backup solution. Let alone another program running in the background sucking up memory and CPU cycles.

This little gem is for Windows. It uses typical software that you probably already have. If not it’s easy to obtain and is also free/open source.

All you need is 7-zip installed and a little knowledge of BATH file programing.

First open up Notepad and copy and paste this code then save it as Backup.bat

@ECHO OFF
SET hr=%time:~0,2%
IF %hr% lss 10 SET hr=0%hr:~1,1%
Set TODAY=%date:~4,2%-%date:~7,2%-%date:~10,4%-%hr%%time:~3,2%%time:~6,2%%time:~9,2%

XCOPY “D:\files\*” “D:\files-backup\backup_%TODAY%” /i /s
“c:\Program Files (x86)\7-Zip\7z.exe” a -tzip “D:\files-backup\backup_%TODAY%.zip” “D:\files-backup\backup_%TODAY%” -mx5
@RD /S /Q “D:\files-backup\backup_%TODAY%”

Naturally you’ll need to edit the code to fit your needs of what drive and directory you want to backup.
The sample code is created for copying D:\files to the final destination with the current date and time added to the directory name. From there 7-Zip is called up to compress or “Archive” the directory and when finished it delete the old directory that was copied before hand.

You could tweak things and add another line of code on the end to copy the zip archive to a flash drive or SD card. Maybe even the “Cloud”

XCOPY “D:\files-backup\*” “E:\” /i /s

Now we don’t want to run this manually since we will probably forget so we can use Task Scheduler to run the task once a day. Just load up Task Scheduler and select create task and follow the prompts and directions.

Give the Task a name, I called mine Backup Documents.
Under Triggers select Daily and the time you want it to run, I run mine at Midnight.
Under Actions select to run a program/script and browse to the Backup.bat file. I keep the file in C:\Tools.

It’s simple and easy.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s