WatchDirectory home page
WatchDirectory Startseite (Deutsche Version)
Site WatchDirectory (Français)
  Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
   
  HomeHelpSearchLoginRegister  
 
Page Index Toggle Pages: 1
auto delete an older file ? (Read 4808 times)
Harald_Childe
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
auto delete an older file ?
Nov 21st, 2003 at 8:40pm
 
Hi
Me again  Grin

Yeap that's the point :
I want to auto-delete last backup file when a newbackup is created in the same directory.
Is it possible ?
Thanks (and have a good week end)
It was Harald calling from Paris, France.
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2233
The Netherlands
Re: auto delete an older file ?
Reply #1 - Nov 22nd, 2003 at 3:12am
 
Just a quick thought:

If you want to keep the current and previous backup, you could do some smart renaming.
I am going to assume that a new backup is created every day.

Let's say your backup program creates files with the extension .backup, you add the following to the top of your .bat file:

[code]
rem only process this script for new files
with a .BACKUP extension
IF NOT %WD_REASON% == FILENEW GOTO :EOF
IF NOT "%WD_FILE_E%" == "BACKUP" GOTO :EOF
[/code]
This makes sure this .bat file will only process new files with the extension .BACKUP. All events for other files will be ignored.
Note that the label :EOF is predefined in .bat scripts for the Windows Nt family, doing a  "GOTO :EOF" causes your .bat file to exit.

Next step, modifying your FILENEW section:
[code]
:FILENEW
rem
rem we are called because there is a new backup file.
rem
rem First remove the backupfile that was created 2 days ago
rem
IF EXISTS "%WD_FILE_D%\BACKUP.YESTERDAY" DEL "%WD_FILE_D%\BACKUP.YESTERDAY"


rem
rem now, rename yesterday's backup to BACKUP.YESTERDAY
rem
REN "%WD_FILE_D%\BACKUP.TODAY" "%WD_FILE_D%\BACKUP.YESTERDAY"

rem
rem Last step, the backup that is made today. Rename it to BACKUP.TODAY
rem
REN "%WD_FILE%" "%WD_FILE_D%\BACKUP.TODAY"
[/code]

Other variations are easy to implement. There is a thread in the HowTo forum that discusses renaming files with a unique numeric extension (file.1, file.2 etc), you could use if you would like to keep more backup files.

Hope this helps,
Gert (Le Pays Bas)
Back to top
« Last Edit: Jan 13th, 2004 at 3:25am by Gert »  

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
Harald_Childe
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Re: auto delete an older file ?
Reply #2 - Nov 22nd, 2003 at 8:47pm
 
Thanks Gert  Cheesy
I'll try on next monday
and will feedback
have a nice weekend
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1