Introduction: Protect Your Ideas, Protect Your Work

Picture of Protect Your Ideas, Protect Your Work

I lost data some days ago through a PC crash. One day's work was lost. :/

  • I save my data in the cloud to prevent a hard disk defect.
  • I use a versioning software so I can restore older versions of my work.

  • I make a backup every day.

But this time I lost my current data before backup. And a temporary file for recovery was also destroyed during the crash.

I would like to show you how I will avoid such data loss in the future.

(This solution is suitable for window systems.)

Step 1: What You Will Need...

You do not have to buy what you need.

  • You need administrator rights
  • An editor, such as Notepad++ or the editor of Windows.

Step 2: Create a Batch File

Picture of Create a Batch File

I have a plan ;)

If you are a programmer or a book author or an picture editor, it is important to have very short backup distances. Maybe even a minute... I want an 10 minutes-backup in different directories so that nothing is overwritten.

First, we need a batch file that starts a back-up program. Windows has its own back-up program called Robocopy. Robocopy is command-line-based and can only be executed in a CMD window. (DOS-Box)

Now it is somewhat difficult, because I am German and have a German Windows. But let's see ...

Open an editor of your choice nd create a file named "backup.bat". The name is unimportant and can be chosen freely.

The command line for Robocopy is as follows:

Robocopy - source - target - files to be backed up - parameter

My batch file looks like:

  • set quelle=D:\Projekte
  • set ziel=D:\Datensicherung\RoboCopy\Backup_%time:~3,1%0
  • robocopy "%quelle%" "%ziel%" *.c /mir /maxage:1

It is not necessary to use variables, but makes the command line clearer. It means the following:

  • set quelle= This is the directory of your data. You can also use "source" or what ever you want instead of "quelle". It's your decision.
  • set ziel= This is the target of your data backup. You can also use "target" or what ever you want instead of "ziel". It's your decision.
    • A new directory is created every 10 minutes. So a total of 6 directories. This is done by the directory description:

    • Backup is the first part of the name, than enclose the time with %

    • %time:~3,1%0 means: Take the current time and extract the first digit of the minute and add a 0.

    • i.e. time is 12:10:34 this means: 0=1, 1=2, 2=:, 3=1, 4=0, 5=:, 6=3, 7=4

    • 3 digit = 1, show only one digit, add a 0 = 3,1%0 . That makes: 00, 10, 20, 30, 40, 50.

    • %time:~0,2% means, take the current time, extract the left digit of the hours and use 2 digits. (0-12/24)

    • %time:~3,2% means, take the current time, extract the left digit of the minutes and use 2 digits (0-59)

  • *.c = The files or data types for backup. You can also use *.txt, *.png, *.xls, everything you need and you can use more than one file extension separated by one space. (*.txt *.cpp *.h)
  • There are a lot of parameters. Use robocopy /? for details!
  • I use /mir. It means: Mirror the directory structure. Backup files, but also delete files!
  • I use /maxage:1. It means: Do not consider files that are older than 1 day.
  • You can append the command "Pause" -> "wait" (?) command so that the window does not close automatically.

Save this batch file to a location of your choice. Start the file and see what happens. It should looks like the screenshot above and one directory should be created at the target place.

Step 3: The Task Scheduler (part1)

Picture of The Task Scheduler (part1)

Windows has a task scheduler, can be found under System / Management.(?)

In German, this calls Windows-Verwaltungsprogramme -> Aufgabenplanung. Otherwise, ask the Windows Assistant for Task Scheduler.

Start the task scheduler. (I have attached an English-language screenshot.)

On the right, select Create Task... And you can see the window on picture 2.

  • Give the task a name and a description. (if you want)
  • The other details in this window can remain as they are.


Step 4: The Task Scheduler (part 2)

Picture of The Task Scheduler (part 2)

Select the Trigger tab.

  • Select "Nach einem Zeitplan" (on a schedule) (the first selection)
  • Select "Einmal" (one time) and enter current date and time.
  • Select "Wiederholen jede:" (repeat task every) 10 Minutes.
  • Select "Für die Dauer von:" (for a duration of) "sofort" (Indefinitely)
  • Select "Ablaufen" (expire) if you want to set an end date/time
  • Select "Aktiviert" (Enabled)

Step 5: The Task Scheduler (part 3)

Picture of The Task Scheduler (part 3)

Select the Action tab:

  • Select "Aktion: Programm starten" (Action: Start a program)
  • Under Program/Script enter the path and name of your batch file. (backup.bat)

No further information is required.

.

Step 6: The Task Scheduler (part 4)

Picture of The Task Scheduler (part 4)

Select the Conditions tab:

I have not specified any conditions, but if you use an Laptop, you could use some conditions...

Step 7: The Task Scheduler (part 5)

Picture of The Task Scheduler (part 5)

Select the Settings tab:

Look at these details carefully. Here you can enter something, if something does not work.

By default, settings 1,4 and 5 are selected and it´s a good choice. I also chose point 2. Take a look at the screenshot.

I think at this point it is not necessary to explain anything.

Step 8: The Final

Picture of The Final

Did you use the break (Pause / wait) in your batch file?

Did you save your new task?

Ok, on the right side, you see a RUN command. Select your task and let him run....

The command window appears and if the pause is included, the window remains open until you close it. Later you should modify your batch so you do not always have to close the window by hand.

A new directory, depending on the time was created in your target directory.

After an hour, the Task created 6 directories and stored your data that was not older than one day.

Wrong programming decisions are no longer a problem.

System crashes are no longer a problem.

But this method should not replace your normal backup and versioning!

Be warned and protect your ideas and work.

Comments

About This Instructable

160views

2favorites

License:

More by tsmeey:Protect your ideas, protect your workAquarium Controller IV - Visualize mySQL to ChartsAquarium Controller III - Logging to MySQL
Add instructable to: