Jump to content

FileCopy every 30 days...


Recommended Posts

Hi guys,

I need to backup a folder every month, and i don't know if someone can help me to create a script like this:

The .exe will not be autostart

It will copy folder every 1th day of the month

If for example i open the exe the 3th, it create the copy if not exist

From next 1th it create another copy of the same directory

In poor words, from 1th to 30th of every month create only one backup if i open the file, and the old folder copy will be deleted.

Thanks

Link to comment
Share on other sites

a cron job would probably be the best idea, since you're not running the file on start-up.

There are several non-cron ways to do this. What I would do is:

Check the file-date of the back-up archive and compare to today.

If the back-up file doesn't exist, run the back-up function.

If > 30 days, run the back-up function.

Else quit.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

These two functions and the macro are probably not all that will be needed, but they could be used..

FileExists() - a function

FileCopy() - a function

@MDAY - a macro

All this and more in the Helpfile! Welcome to the forum!

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

These two functions and the macro are probably not all that will be needed, but they could be used..

FileExists() - a function

FileCopy() - a function

@MDAY - a macro

All this and more in the Helpfile! Welcome to the forum!

Oh, you forgot RunWait() for the 7zip command line archive utility.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Guys i have foud a solution but i dont know how to write it, so please help me

If backup01 exist then $var1

If @mday is equal to a range to day 1 to 15 day then filecopy test folder to "backup01"

$Var1=if @mday is equal to a range to day 16 to day 31 then filecopy test folder to "backup02" and delete "backup01"

I think the idea is good, someone can convert it in autoit script, expecially for the range part

Thank guys :)

Edited by johnmcloud
Link to comment
Share on other sites

The forum works like so...

Option A:

1) You Write your own code, for your own needs. (if you dont know how, then ask yourself how you got here), and at least try.

2) Post your code if you are having problems, detailing the problems you are having, any errors, and what you have tried to fix them.

3) Peaple will help you.

4) Win

Option B:

1) Ask for someone to make you code.

2) Wait,... and wait.... and wait...

3) Lose

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Ok, understood

This is my script:

$Date = @MDAY
If $Date > 01 And $Date < 15 Then       
DirCreate ( @WorkingDir & "\Backup\File di Backup 01-15" )      
DirRemove ( @WorkingDir & "\Backup\File di Backup 15-31" )                       
FileCopy ( @WorkingDir & "\Origine", @WorkingDir & "\Backup\File di Backup 01-15")
EndIf       

If $Date > 16 And $Date < 31 Then       
DirCreate ( @WorkingDir & "\Backup\File di Backup 15-31" )      
DirRemove ( @WorkingDir & "\Backup\File di Backup 01-15" )      
FileCopy ( @WorkingDir & "\Origine", @WorkingDir & "\Backup\File di Backup 15-31" )
EndIf

The problem is i don't now where insert dir exist, because with this script it create backup everyday and everytime i'll start it, but i need only one time in 15 days.

Another question. It's right >1 <15 and >16 <31 or i'm losing some days?

Thanks

Edited by johnmcloud
Link to comment
Share on other sites

Take a look at this (hard because I have been known to fail) :) and see what you think

$Date = @MDAY

Local $s_Dir_01_15 = @WorkingDir & "\Backup\File di Backup 01-15"
Local $s_Dir_16_31 = @WorkingDir & "\Backup\File di Backup 16-31"

Switch $Date
    Case 1 To 15 ;if day is 1st to 15th
        If Not FileExists($s_Dir_01_15) Then ;if \Backup\File di Backup 01-15 does not already exist
            DirCreate($s_Dir_01_15);create it
            DirRemove($s_Dir_16_31);delete old
            FileCopy(@WorkingDir & "\Origine", $s_Dir_01_15);backup
        EndIf
    Case Else
        If Not FileExists($s_Dir_16_31) Then
            DirCreate($s_Dir_16_31)
            DirRemove($s_Dir_01_15)
            FileCopy(@WorkingDir & "\Origine", $s_Dir_16_31)
        EndIf
EndSwitch
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...