Need DB10 Script - To Delete Image Archives Older than 30 Days ?

Discussion in 'Paragon Drive Backup Product Line' started by JosephB, Jun 1, 2010.

Thread Status:
Not open for further replies.
  1. JosephB

    JosephB Registered Member

    Joined:
    Jan 3, 2008
    Posts:
    310
    Paragon_Matt,

    Do you have or can you build me a Paragon Script, for "Drive Backup 10 Pro", that will:


    1. Delete all the Paragon Backup Image - Archive subfolders and their files that are:

    a) Below "my specific" backup parent folder (i.e. g:\Backups\) which have a file creation date older than 30 days (from the day that the script is run).

    b) Also, at the same time, Delete the Archive entry from the DB10 - "Archive_db" database.
    ...... so that an entry no longer shows under the DB10 - GUI's Archive Tab, for an arhive that was older than 30 days and thus deleted in step a) above.


    Note: I am creating Weekly - Full Backup Image Archives (both Entire Hard Disk archives and some partiton archives) and wish to run a Scheduled - Weekly Paragon Script that will Delete the Weekly created Archives (Entire disk archives and partition archives) that have become older than 1 month, at the time the Weekly Paragon - Delete Script is run.
     
  2. Paragon_MattK

    Paragon_MattK Paragon Moderator

    Joined:
    Jan 14, 2010
    Posts:
    176
    Location:
    Irvine, CA
    JosephB,

    I have written a small piece of code to delete backups from a folder that are older than 'x' days. This can be copied and pasted to the end of any script and modified to work on any directory, and to allow any time frame you like.

    Simply change the ARCDIR variable in the first line to the location of your backups, (g:\backups in the example), and if you would like, change the days variable to how long you would like to keep the archives.

    NOTE: This code will delete ANYTHING older than 30 days in the directory you specify, not just archives. So please take care when using it.

    Code:
    SET STRING ARCDIR = "G:/Backups"
    SET VALUE DAYS = 30
    
    SET VALUE COUNTER = 0
    XFIND
    	OPTIONS
    	RESULT		= TEST
    	RECURSIVE	= DIRECTORIES FIRST
    	RECURSIVE LEVEL	= 0
    	START		= STRING(ARCDIR)
    	MASK		= "*.*"
    	SEARCH		= WIDE
    	FILES		= ON
    	DIRECTORIES	= ON
    	ENDOPTIONS
    BEGIN
    SET VALUE COUNTER = VALUE(COUNTER) + 1
    IF((NOWTIME-(FILECREATETIME(STRING(ARCDIR)+"/"+STRING(TEST)))) >= (VALUE(DAYS)*86400)) THEN
    PUSHSTR(STRING(ARCDIR)+"/"+STRING(TEST))
    ENDIF
    ENDXFIND
    
    DO
    SET STRING STR1 = POPSTR
    FILEDELETEDIR(STRING(STR1))
    FILEDELETE(STRING(STR1))
    SET VALUE COUNTER = VALUE(COUNTER) - 1
    WHILE(VALUE(COUNTER) > 0)
    FILEDELETEDIR(STRING(ARCDIR))
    Unfortunately however, it is not possible to remove them from the archive database manually using the PSL scripts.
     
    Last edited: Jun 1, 2010
  3. JosephB

    JosephB Registered Member

    Joined:
    Jan 3, 2008
    Posts:
    310
    Paragon_Matt,


    I have not tried the script yet,

    However, I just realized that sometimes DB10 creates several days of Archive Backups, in the same auto generated Archive Sub-Folder.

    1. Therefore, a Delete script must only Delete the "files" in all Archive sub-folders below the parent folder (G:\Backups), and preserve the sub-folders and *not* delete the Archive sub-folders below the parent folder (G:\Backups). So, this will leave empty archive sub-folders, but that will be okay.

    2. So, I am not sure, does the script you provided delete the sub-folders too ? ... If so, can you create a version that only deletes "files", in all "levels" of sub-folders levels, below the parent folder (G:\Backups) ?
     
  4. JosephB

    JosephB Registered Member

    Joined:
    Jan 3, 2008
    Posts:
    310
    Paragon_Matt



    1. Did you get a chance to review my above question about you script ?

    2. Also, why does DB10 Pro, sometimes create archives created across 2 consecutive days in the same archive folder, as opposed to creating a new unique archive folder for the second consecutive day ? (P.S., So far it appears that if backup archives are created more than 2 days apart they are created in separate unique named folders.)
     
  5. JosephB

    JosephB Registered Member

    Joined:
    Jan 3, 2008
    Posts:
    310
    Paragon_Matt,

    .... Hi Matt,

    Did you get a chance to review my below question, that I posted to you sometime ago, about you script ?



    Code:
    SET STRING ARCDIR = "G:/Backups"
    SET VALUE DAYS = 30
    
    SET VALUE COUNTER = 0
    XFIND
    	OPTIONS
    	RESULT		= TEST
    	RECURSIVE	= DIRECTORIES FIRST
    	RECURSIVE LEVEL	= 0
    	START		= STRING(ARCDIR)
    	MASK		= "*.*"
    	SEARCH		= WIDE
    	FILES		= ON
    	DIRECTORIES	= ON
    	ENDOPTIONS
    BEGIN
    SET VALUE COUNTER = VALUE(COUNTER) + 1
    IF((NOWTIME-(FILECREATETIME(STRING(ARCDIR)+"/"+STRING(TEST)))) >= (VALUE(DAYS)*86400)) THEN
    PUSHSTR(STRING(ARCDIR)+"/"+STRING(TEST))
    ENDIF
    ENDXFIND
    
    DO
    SET STRING STR1 = POPSTR
    FILEDELETEDIR(STRING(STR1))
    FILEDELETE(STRING(STR1))
    SET VALUE COUNTER = VALUE(COUNTER) - 1
    WHILE(VALUE(COUNTER) > 0)
    FILEDELETEDIR(STRING(ARCDIR))
    Unfortunately however, it is not possible to remove them from the archive database manually using the PSL scripts.
     
    Last edited: Jul 26, 2010
Loading...
Thread Status:
Not open for further replies.