Sign in to follow this  
Followers 0
burton

Automatic Backup To Run Only Once Daily

3 posts in this topic

hi

I have my backup done automatically upon each start-up with XCOPY.

REM 30 sec delay

REM TYPE NUL | CHOICE.COM /N /CY /TY,30 >NUL

@echo off

xcopy "c:\officefiles\*.*" d:\BACKUP\ /c /s /r /d /y /i > d:\BACKUP\Main\xcopy.log

REM copy Outlook data

xcopy "D:\Programme\Microsoft Office\archive.pst" d:\BACKUP\Outlook /c /s /r /d /y /i >> d:\BACKUP\Outlook\xcopy.log

The above is saved as a BATCH-file (*.bat) and added to the Autostart-folder.

How can Auto-It check the last backup date beforehand and if it coincides with the 'today's date' which is already saved on my harddisk, to then skip the backup?

Could someone please post me the solution?

Share this post


Link to post
Share on other sites



hi

I have my backup done automatically upon each start-up with XCOPY.

The above is saved as a BATCH-file (*.bat) and added to the Autostart-folder.

How can Auto-It check the last backup date beforehand and if it coincides with the 'today's date' which is already saved on my harddisk, to then skip the backup?

Could someone please post me the solution?

<{POST_SNAPBACK}>

Write a script that:

Uses the @year & @yday and check this against an inifile or registry entry

if different run backup and save to this inifile or registry entry

Something like this (Untested):

If @YEAR & @YDAY <> INIREAD(@ScriptDir & "\my.ini","Backup","LastRun","") Then   
   Run("yourbackup coomand)
   IniWrite(@ScriptDir & "\my.ini","Backup","LastRun", @YEAR & @YDAY)
EndIf

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Considering that you're using the CHOICE command, I'm assuming that you're not using Windows NT/2000. Assuming that you're not using DOS 6.22, perhaps the easiest way would be to utilize Window's Scheduler to maintain the task. (You could also code the batch file to only run once per day by placing the last-run date within a flag file.)

But to answer your question, you could use a combination of FileGetTime and an assortment of the Date related macros within AutoIt to check the modification timestamp of the log file, and launch the batch file accordingly. Honestly though, if you're wanting to use some of AutoIt's functionality, you might as well just port the entire batch file into a single AutoIt script. :ph34r:

Hope this helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0