Creating a backup copy of data

In this example, we consider how you can automate backups using the MouseRobot.

So, periodically, we need to create backups of the folder "D:\folder". We store the backup-files in ZIP-archive in the folder "D:\folder\Backup". The name of the ZIP-file will contain the date and time of creation.

Instead of the folder "D:\folder\" you can specify any other folder on your computer.

1. Create a new task for MouseRobot.

2. We obtain the date and time of file through the built-in functions of MouseRobot.

{Now} - returns the current date and time. The format is set by the computer settings.

To see the format of the date and time on your computer you need to:

add the step "Dialog" to the task
write {Now} in the "Text dialog"
run the macro

A dialog box as shown below will be displayed:

remove the added step

3. Save the current values of date and time in the variable {a}.

add the step "Set variable or call function"
write "{a}" in the field "Variable"

Since" {Now}" may contain invalid for the filename characters (in our case - "/" and ":") it is necessary to replace them by using the "{StrReplace}".

in the field "Value" write "{StrReplace ({StrReplace ({Now}, "/", "_")}, ":", "_")}" - replasing of "/" and ":" in {Now} with the symbol "_".

Now, similarly to the first step you can view the value of "{a}".

4. Create a ZIP-file folder "D:\folder" and save it in the folder "D:\folder\Backup":

add the snippet "Pack Files" to the task

In the field "Options" replace:

{ArchiveFile} by "D:\folder\Backup\folder{a}. zip", where {a} contains the date and time.
{filesToPack} by "D:\folder"

IMPORTANT NOTE! The file name should be enclosed in double quotes (" "), as it can contain spaces.

5. Save the created macro.

6. Run the macro by pressing the button "Run".

After running the macro, ZIP-archive of folder "D:\folder" with the date and time will appear in the folder "D:\folder\Backup".

The automation startup of this macro with the built-in MouseRobot Task Scheduler is considered in the example "Run macros with Scheduler".