Rank: Newbie Groups: Member
Joined: 5/9/2008 Posts: 3
|
I have 5 USB drives that I rotate each day, keeping one or more off site for disaster recovery. I have Cobian set to save 5 copies. When it goes to delete the oldest copy on a drive, it fails saying that it can't find file dated xxxxx.
What it's trying to do is delete the backup that happened five times ago, but that backup would reside on a different USB drive, so it doesn't exist and the delete fails.
How can I get it to just delete the oldest backup on whatever drive happens to be installed at the moment??
|
 Rank: Administration Groups: Administration
Joined: 12/21/2007 Posts: 6,196 Location: Umeå, Sweden
|
There is no magic, so there is no way. Automatic functions work with static drives.
-- Remember folks: Being an administrator doesn't give you automatically full access to all files.
|
Rank: Newbie Groups: Member
Joined: 5/15/2008 Posts: 4
|
cobian wrote:There is no magic, so there is no way. Automatic functions work with static drives. I have the same problem with a backup server that uses removable drive bays. Even though I have it set to keep 10 backups and overwrite the oldest one, it continues to keep creating new backups until the drive fills up. It didn't occur to me that when Cobian tries to delete the oldest backup that it is looking for the same drive. I thought it would just see the oldest modified date in the list of previous backups on the drive being used and delete it. If this is not the case, there is no way to keep the drive from filling up if it is swapped regularly. This means that every week I have to manually delete the oldest backup unless I use the same drive for an indefinite amount of time. Either that or have my client continue to buy new drives. That does not seem practical. I guess an option would be to create a separate backup task that corresponds to a different week and have that task performed monthly. Each task would have a different start date. If the drive is not swapped then I suppose the delete would fail. So for instance if full backups are done on Fridays and I have four drives, I would create 4 full backup tasks. I would have task 1 to start on the first Friday of the month. Let's say June 1st for this example. Full backup task 2 would have a start date of June 13th and so on. The tricky part is when there are five Fridays in one month. The task 4 full backup would have to be configured as weekly and NOT monthly. That way week 4 and 5 would fall under the same task and task 4 would do double duty. If the user fails to remove the task 4 drive after the 5th Friday, the backpup would continue going into week 1 of July or whatever the next month happens to be after that 5th Friday. The user would determine how much overhead is needed in order to figure out how many backups can be done before overwriting so the drives don't fill up. But it is critical that the drives be swapped in order for the overwrite to work properly if I understand Cobian correctly. Am I understanding things right when it comes to this program. Will this solution work?
|
Rank: Newbie Groups: Member
Joined: 5/9/2008 Posts: 3
|
At first glance, your solution might work, however it relies on someone switching the drives on time. In our case, that would doom it to failure. I'm for a nightly routine that runs on Windows to just dump the oldest folder on the drive, whichever drive it might be. I don't know how to do that, though.
|
Rank: Newbie Groups: Member
Joined: 5/15/2008 Posts: 4
|
mrcrab wrote:At first glance, your solution might work, however it relies on someone switching the drives on time. In our case, that would doom it to failure. I'm for a nightly routine that runs on Windows to just dump the oldest folder on the drive, whichever drive it might be. I don't know how to do that, though. Yeah true which is what makes it so critical. My client however does not swap the drives religiously so tracking backups is a challenge. You would think it would be easy to write a routine in the program that looks at the folder's (or file's) modifed date and delete the oldest one.
|
Rank: Newbie Groups: Member
Joined: 11/25/2008 Posts: 2
|
I also swap drives daily and quickly found that Cobian doesn't accurately delete the older files in this situation. It seems that Cobian "calculates" the file name to be deleted rather than looking at time/date stamps and nuking the oldest ones. I have attached a VB Script routine to be run (by Cobian or in a separate scheduled event - I use Cobian) after the backup has completed. This has been in operation for a week or so and seems to do the trick. The comments at the beginning of the program list how to specify the run parameters. To set it up in Cobian browse for the executable to \windows\system32\cscript.exe. The arguments to cscript are \script location\bakdel.vbs maxkeep=x path=xxxx pattern=xxxx so the final string for execution should look something like:
c:\windows\system32\cscript.exe c:\scripts\bakdel.vbs maxkeep=n path=xxxx pattern=xxxx
blanks are used by cscript to separate parameters so if either your path or pattern contain blanks use the format
maxkeep=n "path=xx yyy" pattern=xxxx
Hope y'all find this useful.
' ------------------------------------------------------------------------------- ' ' BakDel.vbs ' ' CScript routine to erase old backup files mismanaged by both Ghost and Cobian ' Backup. Both programs apparently assume that all previous backups are still ' online and therefore look for specific backup dates to delete when a retention ' restriction is placed on the backups. When more than one backup device is used ' (swapped) this assumption is invalid. This routine looks at the file last ' modified date for the backup files and deletes the oldest files until the ' desired retention number (MaxKeep) is realized.
' The routine obtains its run parameters via command line keyword= syntax. The ' REQUIRED keywords are as follows:
' Path= provide a normal path specification in the form drive:\folder... to ' identify where the backup files are located. If the path contains ' blanks the whole parameter should be enclosed in quotes. ' e.g., "Path=g:\Backup Files"
' MaxKeep= The number of backups to be retained.
' Pattern= The format of the backup file name so that other files may reside in ' the backup folder without danger of erasure. Normal DOS wildcard ' usage applies. Some samples:
' For Cobian: ' "Pattern=C 20*.zip" where a typical file would be named ' C 2008-11-10 20;00;03.zip ' For Ghost: ' Pattern=NED_C_DRIVE*.v* where a typical file would be named ' NED_C_DRIVE184.v2i ' ' If backups for different drives are maintined in the same folder this routine ' should be invoked multiple times, attempting deletions of only the files for ' one drive each time. ' ' Ned Robertson ' Baldwin Associates ' Melbourne, FL ' ' --------------------------------------------------------------------------------
Option Explicit
Dim aFileArray( 100, 2 ) ' candidates for deletion. Col 0 = file name(s), ' Col 1 = Timedate stamp Dim cPath, nMaxKeep, cPattern 'Run Parameters Dim nF, sFileName Dim oArgs, oFS, oFolder, oFiles, oFile Dim i, j, sName, dDate
cPath = "" nMaxKeep = -1 cPattern = ""
Set oArgs = WScript.Arguments
IF GoodArgs( oArgs ) Then ' Proceed only if args OK
nF = -1 ' Pre-load candidate file count
Set oFS = CreateObject( "Scripting.FileSystemObject" )
Set oFolder = oFS.GetFolder( cPath )
Set oFiles = oFolder.Files
For Each oFile In oFiles ' Loop thru files picking candidates
sFileName = oFile.Name
If IsCandidate( sFileName, cPattern ) Then
nF = nF + 1
aFileArray( nF, 1 ) = sFileName aFileArray( nF, 2 ) = FmtDateTime( oFile.DateLastModified )
End If
Next
If nMaxKeep < nF + 1 Then
For i = 0 To nF - 1
For j = i + 1 To nF ' Sort candidates descending by date and time
If aFileArray( i, 2 ) < aFileArray( j, 2 ) Then
sName = aFileArray( i, 1 ) dDate = aFileArray( i, 2 )
aFileArray( i, 1 ) = aFileArray( j, 1 ) aFileArray( i, 2 ) = aFileArray( j, 2 )
aFileArray( j, 1 ) = sName aFileArray( j, 2 ) = dDate
End If
Next ' j
Next ' i
For i = nMaxKeep TO nF ' and nuke unwanted oldies
oFS.DeleteFile( cPath & "\" & aFileArray( i, 1 ) )
Next ' i
End If
End If
' -------------------------------------------------------------------------
Function GoodArgs( oArgs ) ' Collect and check arguments
Dim lReturn Dim sArg, sArgt, sData, sDun, sWork
lReturn = "True" sDun = ""
For Each sArg In oArgs
sArgt = UCase( sArg )
If 0 <> InStr( 1, sArgt, "PATH=" ) Then
cPath = Mid( sArgt, InStr( 1, sArgt, "=" ) + 1 )
Do While Right( cPath, 1 ) = "\" And Len( cPath ) > 0
cPath = Left( cPath, Len( cPath ) - 1 )
Loop
sDun = sDun + "P"
ElseIf 0 <> InStr( 1, sArgt, "MAXKEEP=" ) Then
sWork = Mid( sArgt, InStr( 1, sArgt, "=" ) + 1 )
If IsNumeric( sWork ) Then
nMaxKeep = Int( Eval( sWork ) )
If nMaxKeep < 1 Then
lReturn = "False"
End If
Else
lReturn = "False"
End If
sDun = sDun & "K"
ElseIf 0 <> InStr( 1, sArgt, "PATTERN=" ) Then
cPattern = Mid( sArgt, InStr( 1, sArgt, "=" ) + 1 )
sDun = sDun & "A"
End If
Next
GoodArgs = lReturn AND 0 <> InStr( 1, sDun, "P" ) AND _ 0 <> InStr( 1, sDun, "K" ) AND _ 0 <> Instr( 1, sDun, "A" )
End Function
' ----------------------------------------------------------------------------
Function IsCandidate( cCand, cPattern ) ' Match filename to pattern
Dim cPatL, cPatR, cCandL, cCandR
cCand = UCase( cCand ) cPattern = UCase( cPattern )
cPatL = Left( cPattern, InStr( 1, cPattern, "." ) - 1 ) cPatR = Right( cPattern, Len( cPattern ) - Len( cPatL ) - 1 )
cCandL = Left( cCand, Instr( 1, cCand, "." ) - 1 ) cCandR = Right( cCand, Len( cCand ) - Len( cCandL ) - 1 )
IsCandidate = IsCandSub( cCandR, cPatR ) AND IsCandSub( cCandL, cPatL )
End Function
' ----------------------------------------------------------------------------
Function IsCandSub( cCand, cPat ) ' Parse filename fragment
Dim cTemp, lOK, i
lOK = "True"
For i = 1 TO Len( cCand )
cTemp = Mid( cPat, i, 1 )
If cTemp = "*" Then
Exit For
ElseIf cTemp = "?" OR cTemp = Mid( cCand, i, 1 ) Then
' Loop
Else
lOK = "False"
Exit For
End If
Next
IsCandSub = lOk
End Function
' ----------------------------------------------------------------------------
Function FmtDateTime( sDT )
Dim sDate, sTime, n
sDate = Left( sDT, InStr( 1, sDT, " " ) - 1 ) sTime = Right( sDT, Len( sDT ) - ( Len( sDate ) + 1 ) )
If InStr( 1, sDate, "/" ) = 2 Then sDate = "0" & sDate
If Len( sDate ) = 9 Then sDate = Left( sDate, 3 ) & "0" & Right( sDate, 6 )
sDate = Right( sDate, 4 ) & Left( sDate, 2 ) & Mid( sDate, 4, 2 ) ' yyyymmdd
If InStr( 1, sTime, ":" ) = 2 Then sTime = "0" & sTime
If Right( sTime, 2 ) = "PM" Then
sTime = FormatNumber( Eval( Left( sTime, 2 ) ) + 12, 0 ) + Mid( sTime, 3, 9 )
End If
FmtDateTime = sDate & Left( sTime, 8 ) ' yyyymmddhh:mm:ss (24hr clock)
End Function
' ----------------------------------------------------------------------------
|
Rank: Newbie Groups: Member
Joined: 4/22/2008 Posts: 7 Location: France
|
Hi,
I have this problem too, using cobian8 working with 2 USB hard drive that I not religiously swap everyday...and, and scrooge seems to give us a good solution, but in my case, I'm just unable to write this script; I just don't know how to do. With notepad?
thx
|
Rank: Member Groups: Member
Joined: 5/29/2008 Posts: 27 Location: Locarno, Switzerland
|
Hello everybody.
Since backing up to a local USB drive when using ZIP compression is way too slow, I'm backing up without compression (each backup = one directory tree). Is there any way to have the posted script (excellent!) modified to get it's job done also with directory trees and not only ZIP files?
If not, would there be any chance to get the ZIP faster on the USB drive?
Thanks, F.
|