Error Copying 'globalprefs.oxc'

I have a script that runs a nightly Opus config backup. Since installing DO13, I have received this error, which I suspect is connected to the script:

image

Here's the script:

Summary
Option Explicit

Dim ActionList, IntervalList
Set ActionList = DOpus.NewVector(1, "delete", "rename", "replace")
Set IntervalList = DOpus.NewVector(2, "minute(s)", "hour(s)", "day(s)", "month(s)")

Function OnInit(InitData)
   InitData.name = "Settings Auto Backup"
   InitData.desc = "Automatically creates backups of settings with specified interval in user defined folder."
   InitData.copyright = "(C) 2014 TVB"
   InitData.version = "1.1"
   InitData.min_version = "11"
   InitData.default_enable = False
   InitData.config.Action = ActionList
   InitData.config.Amount = 0
   InitData.config.Copy = "all"
   InitData.config.Description = ""
   InitData.config.FilePath = ""
   InitData.config.FileName = ""
   InitData.config.Global = True
   InitData.config.Interval = IntervalList
   InitData.config.Number = 1
   InitData.config.OnStartup = False
   InitData.config.OnOpenLister = True
   InitData.config.OnOpenTab = False
   InitData.config.OnDisplayModeChange = True
   InitData.config.OnListerUIChange = True
   InitData.config.OnStyleSelected = True
   InitData.config.OnCloseTab = False
   InitData.config.OnCloseLister = True
   InitData.config.OnShutdown = False
   InitData.config.OnTimer = True
   InitData.config.Password = ""
   InitData.config.Remove = DOpus.NewVector
End Function

Function OnStartup(StartupData)
   If Script.config.OnTimer Then
      Do
         Call DoSettingsBackup
         DOpus.Delay(60 * 1000)
      Loop
   ElseIf Script.config.OnStartup Then
      Call DoSettingsBackup
   End If
End Function

Function OnOpenLister(OpenListerData)
   If Script.config.OnOpenLister And Not Script.config.OnTimer Then
      Call DoSettingsBackup
   End If
End Function

Function OnOpenTab(OpenTabData)
   If Script.config.OnOpenTab And Not Script.config.OnTimer Then
      Call DoSettingsBackup
   End If
End Function

Function OnDisplayModeChange(DisplayModeChangeData)
   If Script.config.OnDisplayModeChange And Not Script.config.OnTimer Then
      Call DoSettingsBackup
   End If
End Function

Function OnListerUIChange(ListerUIChangeData)
   If Script.config.OnListerUIChange And Not Script.config.OnTimer Then
      Call DoSettingsBackup
   End If
End Function

Function OnStyleSelected(StyleSelectedData)
   If Script.config.OnStyleSelected And Not Script.config.OnTimer Then
      Call DoSettingsBackup
   End If
End Function

Function OnCloseTab(CloseTabData)
   If Script.config.OnCloseTab And Not Script.config.OnTimer Then
      Call DoSettingsBackup
   End If
End Function

Function OnCloseLister(CloseListerData)
   If Script.config.OnCloseLister And Not Script.config.OnTimer Then
      Call DoSettingsBackup
   End If
End Function

Function OnShutdown(ShutdownData)
   If Script.config.OnShutdown And Not Script.config.OnTimer Then
      Call DoSettingsBackup
   End If
End Function

Sub DoSettingsBackup
   Dim Action, Amount, File, FileDate, FileDateFormat, FileExt, FileList, FileName, FilePath, FilePathName, FilePathNameExt, Folder, FSO, i, Interval, Size
   FilePath = DOpus.FSUtil.Resolve(Trim(Script.config.FilePath))
   FileName = Trim(Script.config.FileName)
   If FilePath <> "" And FileName <> "" Then
      If Right(FilePath, 1) <> "\" Then
         FilePath = FilePath & "\"
      End If
      FilePathName = FilePath & FileName
      FileExt = "ocb"
      FilePathNameExt = FilePath & FileName & "." & FileExt
      Set FSO = CreateObject("Scripting.FileSystemObject")
      If DOpus.FSUtil.Exists(FilePathNameExt) Then
         Set File = FSO.GetFile(FilePathNameExt)
         Action = ActionList(Script.config.Action + 1)
         FileDate = File.DateLastModified
         FileDateFormat = Year(FileDate) & "-" & Right("0" & Month(FileDate), 2) & "-" & Right("0" & Day(FileDate), 2) & "_" & Right("0" & Hour(FileDate), 2) & "." & Right("0" & Minute(FileDate), 2) & "." & Right("0" & Second(FileDate), 2)
         Interval = IntervalList(Script.config.Interval + 1)
         If Interval = IntervalList(1) Then
            Interval = "n"
         Else
            Interval = Left(Interval, 1)
         End If
         If DateDiff(Interval, FileDate, Now) >= Script.config.Number Then
            Call CommandList(Action, FileDateFormat, FileExt, FilePathName, FilePathNameExt)
            Amount = Script.config.Amount
            If Amount > 0 Then
               Set FileList = DOpus.NewVector
               Set Folder = FSO.GetFolder(FilePath)
               i = 0
               For Each File In Folder.Files
                  If InStr(1, File.Name, FileName & "_", 1) <> 0 And LCase(FSO.GetExtensionName(File.Name)) = FileExt Then
                     FileList(i) = File.Name
                     i = i + 1
                  End If
               Next
               Size = FileList.size
               Amount = Size - Amount
               If Size > Amount Then
                  For i = 0 To Amount
                     DOpus.NewCommand.RunCommand("Delete FILE FORCE RECYCLE QUIET """ & FilePath & FileList(i) & """")
                  Next
               End If
            End If
         End If
      Else
        Call CommandList("", "", "", FilePathName, FilePathNameExt)
      End If
   End If
End Sub

Sub CommandList(Action, FileDateFormat, FileExt, FilePathName, FilePathNameExt)
   Dim Args, Description, i, OpusCmd, Password, RemoveList, Size
   Set OpusCmd = DOpus.NewCommand
   If Action = "delete" Then
      OpusCmd.RunCommand("Delete FILE FORCE RECYCLE QUIET """ & FilePathNameExt & """")
   ElseIf Action = "rename" Then
      OpusCmd.RunCommand("Rename AUTORENAME """ & FilePathNameExt & """ TO """ & FilePathName & "_" & FileDateFormat & "." & FileExt & """")
   End If
   Args = Replace(Script.config.Copy, " ", "")
   If Args <> "" Then
      Args = "BACKUP=" & Args & " "
   Else
      Args = "BACKUP "
   End If
   Description = Trim(Script.config.Description)
   If Description <> "" Then
      Description = "DESC=""" & Description & """ "
   End If
   Password = Trim(Script.config.Password)
   If Password <> "" Then
      Password = "PASSWORD=""" & Password & """ "
   End If
   OpusCmd.RunCommand("Prefs " & Args & Description & Password & "QUIET TO """ & FilePathName & """")
   If DOpus.FSUtil.Exists(FilePathNameExt) Then
      If Script.config.Global Then
         OpusCmd.RunCommand("Copy FILE CREATEFOLDER=""Global Data"" ""/dopusglobaldata\Global Data\*.oxc"" TO """ & FilePathNameExt & """")
      End If
      Set RemoveList = Script.config.Remove
      Size = RemoveList.size
      If Size > 0 Then
         For i = 0 To Size - 1
            OpusCmd.RunCommand("Delete FORCE NORECYCLE QUIET """ & FilePathNameExt & "\" & RemoveList(i) & """")
         Next
      End If
   End If
End Sub

Any ideas?

My guess is the destination path it's trying to copy to is invalid. From a quick look at the code, it seems to be trying to copy files to a folder with the same name as the script, or assumes there's a .OCB file somewhere with the same name as the script, or something? That destination is probably missing on your machine now.

Something doesn't add up. It appears to me the file path and file name are correctly identified in the script settings. To reiterate, this error started with the DO13 install.

FYI: This script originated here: Settings Auto Backup (Normal and USB). I am using version 1.1

Script settings:

Paths and files in question:

I attempted to change the path below to the full path, but no success.

If Script.config.Global Then
         OpusCmd.RunCommand("Copy FILE CREATEFOLDER=""Global Data"" ""C:\ProgramData\GPSoftware\Directory Opus\Global Data\*.oxc"" TO """ & FilePathNameExt & """")
		 'OpusCmd.RunCommand("Copy FILE CREATEFOLDER=""Global Data"" ""/dopusglobaldata\Global Data\*.oxc"" TO """ & FilePathNameExt & """"
      End If

It appears globalprefs.oxc was last updated 10/3/2023, which aligns with when I installed DO13. File contents:

<?xml version="1.0" encoding="UTF-8"?>
<globalprefs />

The script appears to function appropriately, with the exception of the globalprefs.oxc file. In addition, it appears this file can be skipped in the backup process by setting Global to false.

That said, please help me understand:

  1. What is the purpose of globalprefs.oxc?
  2. For what purpose does DO13 require this file?
  3. The script otherwise works, so what could cause the script to fail if both the path and file exist?

Taking a step back: what are the advantages of this script compared to Opus' built-in backup command?

Fair question. I am constantly tinkering and prefer to do a nightly backup that does not require my presence.

Here's the existing Backup and Restore Configuration dialog:

We have the where, what, and how. There is no WHEN to fully automate the process.

That said, if there's a way to do this that negates the need for the particular script I am using, please enlighten me.

I create a backup on every startup. I do it with a script, but you can simply put

Prefs BACKUP=all TO="/path\to\my\backup\Opus.Config.{date|yyyyMMdd}-{time|HHmmss}.ocb" QUIET

into Preferences / Launching Opus / Startup / Run a command.

This only occurs when starting DOpus from scratch, with dopusrt.exe not already running in the background. Do I have that correct?

If so, then if I leave DOpus running - which I do - the backup does not occur until I conduct a full DOpus restart, which seems a partial solution but not what I'm after.

Yes. In that case, I'd use the Windows task scheduler and dopusrt to launch the command.

Thanks for the suggestion. I will take a look at this option, although I'm still curious as to what may be happening with the script.

The script copies TO """ & FilePathNameExt & """", and my guess was that FilePathNameExt doesn't exist (or is a file, not a folder).

Making the script output the command it runs is what I would do first if I was debugging it. Then you can see if what it is doing makes sense.

@Leo Thanks will investigate further.

@Leo FilePathNameExt = C:\Users\Chuck\Documents\DOpus\Configs\DOpus Backup (Auto).ocb

If I'm understanding this correctly, it's indicating the file "DOpus Backup (Auto).ocb" when it should be indicating the containing folder "C:\Users\Chuck\Documents\DOpus\Configs" only.

Do I have that right?

Depends where you want the file to go, but yes, that wouldn’t work as-is unless .ocb had been added to the list of Zip extensions (which isn’t unusual if you want to look inside the backups, but isn’t something the script should assume is set up either).

Maybe the script should be making a .zip not a .ocb

@Leo Thanks for the feedback. Unless you indicate otherwise, I'm not seeing value using the Global portion of the script given the file is essentially empty and has not been updated. Setting Global to false cleared the error.