TIP OF THE DAY: Inteligent cleaning of SW Backups

Discussion in 'SolidWorks' started by P., Mar 15, 2005.

  1. P.

    P. Guest

    If you are like me you have SW backups set to 2 copies in the very
    unlikely event that you make a mistake and have to go back and restore
    a SW document. This leads to another distasteful task, cleaning out the
    SW Backup directory from time to time. One of my associates pointed out
    that he likes to keep 3 days of backups. So how to keep 3 days of
    backups without spending time every day manually deleting files? Enter
    DELOLD and the Task Scheduler.

    1. Goto
    http://www.experts-exchange.com/Operating_Systems/MSDOS/Q_21238420.html
    and grab this command file using cut and paste. Paste it into notepad
    and save to a convenient place on your system's search path with the
    name DELOLD.CMD.

    2. Create another command file called SWCLEAN.CMD and put in:

    CD "SW Backup Directory"
    DELOLD 4 *.SLD*

    3. Create a task in the Task Scheduler that runs SWCLEAN.CMD at some
    early hour of the morning.

    4. Before letting this go and run, test SWCLEAN.CMD. If all is well
    edit DELOLD.CMD and replace ECHO with DEL so that it actually deletes
    files.

    Note that you could also add a line to SWCLEAN.CMD to clean out your
    temp directory and defragment. Defragment is simply DEFRAG C:
     
    P., Mar 15, 2005
    #1
  2. P.

    P. Guest

    In the spirit of Beta testing with users many thanks.

    I think it has to do with the spaces in the path or filename. I didn't
    write the cmd file so it will take a bit of sleuthing to figure out how
    to deal with the more modern filenames. As far as the path goes try
    CDing to the backup directory in the batch file that calls the delete
    program.

    If this is a good idea I suppose it could be translated into a macro
    within SW or a shell script.
     
    P., Mar 15, 2005
    #2
  3. P.

    CS Guest

    To use a file name with spaces you have to enclose it with Quotes in any app
    that uses the console.

    Corey
     
    CS, Mar 16, 2005
    #3
  4. P.

    P. Guest

    and the fix is.....................

    DEL /P "%FileName%"

    put quotes around the filename (and add a /P for checking).
     
    P., Mar 16, 2005
    #4
  5. P.

    P. Guest

    Are you running XP and using it from cmd not command? I didn't have any
    trouble in my backup directory and I have spaces in filenames.
     
    P., Mar 16, 2005
    #5
  6. P.

    P. Guest

    Try this. After reading the help I noticed it doesn't take a filename
    as a second argument so I added that.

    :: --------DELOLD.BAT----------
    @echo off
    SET OLDERTHAN=%1
    SET SEARCHFOR=%2
    IF NOT DEFINED OLDERTHAN GOTO SYNTAX
    IF NOT DEFINED SEARCHFOR SET SEARCHFOR="*.*"

    for /f "tokens=2" %%i in ('date /t') do set thedate=%%i

    set mm=%thedate:~0,2%
    set dd=%thedate:~3,2%
    set yyyy=%thedate:~6,4%

    set /A dd=%dd% - %OLDERTHAN%
    set /A mm=%mm% + 0

    if /I %dd% GTR 0 goto DONE
    set /A mm=%mm% - 1
    if /I %mm% GTR 0 goto ADJUSTDAY
    set /A mm=12
    set /A yyyy=%yyyy% - 1

    :ADJUSTDAY
    if %mm%==1 goto SET31
    if %mm%==2 goto LEAPCHK
    if %mm%==3 goto SET31
    if %mm%==4 goto SET30
    if %mm%==5 goto SET31
    if %mm%==6 goto SET30
    if %mm%==7 goto SET31
    if %mm%==8 goto SET31
    if %mm%==9 goto SET30
    if %mm%==10 goto SET31
    if %mm%==11 goto SET30
    if %mm%==12 goto SET31

    goto ERROR

    :SET31
    set /A dd=31 + %dd%
    goto DONE

    :SET30
    set /A dd=30 + %dd%
    goto DONE

    :LEAPCHK
    set /A tt=%yyyy% %% 4
    if not %tt%==0 goto SET28
    set /A tt=%yyyy% %% 100
    if not %tt%==0 goto SET29
    set /A tt=%yyyy% %% 400
    if %tt%==0 goto SET29

    :SET28
    set /A dd=28 + %dd%
    goto DONE

    :SET29
    set /A dd=29 + %dd%

    :DONE
    if /i %dd% LSS 10 set dd=0%dd%
    if /I %mm% LSS 10 set mm=0%mm%
    for %%i in (%SEARCHFOR%) do (
    set FileName=%%i
    call :pROCESSFILE %%~ti
    )

    set mm=
    set yyyy=
    set dd=
    set thedate=
    goto EXIT

    :SYNTAX
    ECHO.
    ECHO USAGE:
    ECHO DELOLD X [FILENAME]
    ECHO Where X is the number of days previous to Today.
    ECHO Where FILENAME is an optional filename or wildcards.
    ECHO.
    ECHO EX: "DELOLD 5" Deletes files older than 5 days.
    GOTO EXIT

    :pROCESSFILE
    set temp=%1
    set fyyyy=20%temp:~6%
    set fmm=%temp:~0,2%
    set fdd=%temp:~3,2%
    if /I %fyyyy% GTR 2069 set fyyyy=19%temp:~6%


    :: +*************************************+
    :: | This is where the files are deleted |
    :: | Change the ECHO command to DEL to |
    :: | delete. ECHO is used for test. |
    :: +*************************************+
    if /I %yyyy%/%mm%/%dd% GEQ %fyyyy%/%fmm%/%fdd% (
    ECHO "%FileName%"
    )

    set temp=
    set fyyyy=
    set fmm=
    set fdd=

    :EXIT

    :: ----------END-DELOLD.BAT-------------
     
    P., Mar 17, 2005
    #6
  7. P.

    P. Guest

    Boy, have they increased the capablities of batch files in XP. I am
    going through this thing now bit by bit trying to understand it. If
    Windoze main feature over DOS and Unix was ease of use then Unix has
    them beat in writing understandable shell files.
     
    P., Mar 17, 2005
    #7
  8. P.

    John Layne Guest

    I use this free little utility to empty temp files inclusive the
    contents of the SolidWorks Autobackup folder. I have it set to delete
    files older than 30 days

    http://www.danish-shareware.dk/soft/emptemp/


    Regards

    John Layne
    Solid Engineering Ltd
     
    John Layne, Mar 20, 2005
    #8
  9. Here is another method to consider, the one I'm currently using:
    External Hard Drives.
    I set the SolidWorks Back-Up settings to "Zero". It takes time to read/write
    these back-up files every time you "Save".I back up to an External Hard
    Drive #1 every 30 minutes or so. I also delete all Temp files every 4 hours
    or so. The keeps the Internal Drives on my computer clean. Then, one a week,
    I back up the #1 Hard Drive to External Hard Drive #2. I also Defrag my
    Internal and External Hard Drives at the end of everyday.
    I also recommend the method of keeping the Applications on the C: Drive and
    all Data on another Internal Hard Drive.
    Best Regards,
    Devon T. Sowell
    www.3-ddesignsolutions.com
     
    Devon T. Sowell, Mar 21, 2005
    #9
  10. P.

    P. Guest

    Devon,

    That is a very good insight. I like Layne's idea too. There is a batch
    file on the SW site that does a lot of cleanup and I wanted to
    integrate to that. But your idea of not using SW backups has some
    merit. The only issue with it is that I like the backups because it is
    a means of undo and I work both on local drives and on network drives.
    It would be kind of hard to track where I was working and only back
    that up. Since SW backup is done to a local drive that is very fast and
    the second copy is just a rename operation I don't think I am loosing
    that much by leaving SW backup set to 2.

    Layne's idea with a little customization for SW might be very helpful.
    I also have FEA temp files that can get very large, sometimes several
    GB. And they can be anywhere so they have to be found by extension, but
    some of the extensions are common to Windows system extensions.
     
    P., Mar 21, 2005
    #10
  11. P.

    John Layne Guest

    Hi Devon

    Another utility I use to backup at the end of each day is ViceVersa Pro.
    It's not free but well worth the cash.

    http://www.tgrmn.com/

    I find it invaluable as it has excellent control over what’s being
    backed up or synchronized.

    My Methodology using ViceVersa:

    C Drive Internal 80Gb ATA
    F Drive Internal 120Gb SATA Raid 0 array (working files)
    H Drive External 40Gb USB Drive

    At the end of each day I “Replicate and Prune” working folders from F
    drive "Source" to C drive "Target". Hence the working folders on C
    become a mirror of F.

    I then backup F "Source" to H "Target" using the “Advanced Sync with
    History” method and have it set to keep the previous 10 copies of any
    particular file, it’s also set to delete backup files older than 6
    months. The "Advanced Sync" method allows me to work on the USB drive
    from my home office and return to my clients and sync with my PC located
    at their office. This method is also used to sync with their server.

    My data files occupy approximately 20GB. Due to only updated files being
    backed up the entire process above takes about 5 minutes.

    Below an extract from the ViceVersa help file on Synchronization Methods
    the software has


    "Simple Sync (No History)"
    *All single (=unpaired) files and folders in the Source are copied to
    the Target.
    *All single (=unpaired) files and folders in the Target are copied to
    the Source.
    *Older files in the Target are replaced with their newer counterpart in
    the Source.
    *Older files in the Source are replaced with their newer counterpart in
    the Target.

    "Replication (Augment)"
    *All single (=unpaired) files and folders in the Source are copied to
    the Target.

    "Replication (Refresh)"
    *Older files in the Target are replaced with their newer counterpart in
    the Source.

    "Replication (Update)"
    *All single (=unpaired) files and folders in the Source are copied to
    the Target.
    *Older files in the Target are replaced with their newer counterpart in
    the Source.

    "Replication (Update and Prune)"
    *All single (=unpaired) files and folders in the Source are copied to
    the Target.
    *Older files in the Target are replaced with their newer counterpart in
    the Source.
    *All single (=unpaired) files and folders in the Target are removed
    (pruned).

    "Replication (Mirror)" Creates a mirror of the Source in Target = Backup
    Source(s) to Target(s)
    *All single (=unpaired) files and folders in the Source are copied to
    the Target.
    *Older files in the Target are replaced with their newer counterpart in
    the Source.
    *Newer files in the Target are replaced with their older counterpart in
    the Source.
    *All single (=unpaired) files and folders in the Target are removed
    (pruned).

    "Advanced Sync (With History)" Bidirectional Synchronization
    *All newly added files and folders in Source since last sync are copied
    to Target and vice versa.
    *All deleted files and folders in Source since last sync are deleted
    from Target and vice versa.
    *Newer files in Source are copied over their older counterpart in Target
    and vice versa.
    *If a file was changed both in Source AND Target, the file is identified
    as a conflict.


    Regards

    John Layne
    Solid Engineering Ltd
     
    John Layne, Mar 21, 2005
    #11
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.