Friday, November 6, 2009

BackupExec on Linux : /opt/VRTSralus/bin/beremote daemon stops unexpectedly

When making backups of my linux server, I can have errors on open files generating errors... but the issue is that the backupexec remote agent stops running and then is unavailable for the next job.
A workaround consists in checking every hour (in this example) if the agent daemon (/opt/VRTSralus/bin/beremote) is still running, and if stopped, restart it.

Create the following script file (/root/restartRalus.sh) :

if [ -f /bin/grep ]
then
  PID=`/bin/ps -e | /bin/grep beremote | /bin/sed -e 's/^ *//' -e 's/ .*//'`
else
  PID=`/usr/bin/ps -e | /usr/bin/grep beremote | /usr/bin/sed -e 's/^ *//' -e 's/ .*//'`
fi

if [ "${PID}" = "" ]
then
  /etc/init.d/VRTSralus.init start
fi



And execute it every hour for example :
> crontab -e
> 0 * * * * sh /root/restartRalus.sh

Thursday, November 5, 2009

VB Script to get folder and subfolders sizes with treedepth...

In order to have an automated overview of space amount used in my backup job, I made this vbs script.
Create a FolderList.txt file with pathes to folders you want to scan (don't leave blank lines)
Set the values you want for :
isProcessFiles : Get files size too
treeDepth : tree depth when scanning folders
computeAllFoldersSize : compute full size of all folders


Const isProcessFiles = 1
Const treeDepth = 3
Const computeAllFoldersSize = 1

Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8


Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSO.CreateTextFile(".\FolderSizes.log")

if computeAllFoldersSize = 1 then
  fullSize = 0
  Set objTextFile = objFSO.OpenTextFile(".\FolderList.txt", ForReading)
  Do Until objTextFile.AtEndOfStream
    strFolderPath = objTextFile.Readline
    Set objFolder = objFSO.GetFolder(strFolderPath)
    fullSize = fullSize + objFolder.size
  Loop
  objLogFile.Writeline "Size of all folders in list file : " & FormatNumber(fullSize/(1024*1024*1024),3) & " GB"
  objLogFile.Writeline ""
  objTextFile.Close
End If


if treeDepth < 1 then wscript.quit


'For all folders specified in the text file
Set objTextFile = objFSO.OpenTextFile(".\FolderList.txt", ForReading)

Do Until objTextFile.AtEndOfStream
  strFolderPath = objTextFile.Readline
  Set objFolder = objFSO.GetFolder(strFolderPath)
  ProcessFolder (objFolder)
Loop



Sub ProcessFolder(objCurrentFolder)
  objLogFile.Writeline FormatNumber(objCurrentFolder.Size/(1024*1024),0) & " MB " & objCurrentFolder.path
  if treeDepth > 1 then Call ProcessSubFolders (objCurrentFolder, 1)
End Sub



Sub ProcessSubFolders(ByRef objCurrentFolder, ByVal currentRecurseLevel)

  if currentRecurseLevel >= treeDepth then exit Sub

  recurseTabs = ""
  For value = 0 To currentRecurseLevel - 1
    recurseTabs = recurseTabs & " "
  Next

  if objCurrentFolder.SubFolders.count = 0 then
    if isProcessFiles = 1 then
      Call ProcessFiles (objCurrentFolder, currentRecurseLevel)
    end if
  else
    Call ProcessFiles (objCurrentFolder, currentRecurseLevel)
    For Each objCurrentSubFolder In objCurrentFolder.SubFolders
      objLogFile.Writeline recurseTabs & FormatNumber(objCurrentSubFolder.Size/(1024*1024),0) & " MB " & objCurrentSubFolder.path
      Call ProcessSubFolders (objCurrentSubFolder, currentRecurseLevel + 1)
    Next
  end if
End Sub



Sub ProcessFiles (ByRef objCurrentFolder, ByVal currentRecurseLevel)

   if currentRecurseLevel >= treeDepth then exit Sub

   recurseTabs = ""
   For value = 0 To currentRecurseLevel - 1
     recurseTabs = recurseTabs & " "
   Next

   For Each objCurrentFile In objCurrentFolder.Files
     objLogFile.Writeline recurseTabs & FormatNumber(objCurrentFile.Size/(1024*1024),0) & " MB " & objCurrentFile.path
   Next
End Sub