Backup PC SDK Problem




I am trying to use the Backup call on a 5.12 RAB PC SDK application with a controller running 5.11.3 when I execute the code below after getting mastership of the controller I get the exception "Unable to create directory"  If I use the same code on the Virtual controller running on the same PC as my application it works fine.  Anybody have any Ideals why that is.

    Dim BackupDir As String = ""
    BackupDir = "ctrl:C:/Backup"
        Try
          controller.Backup(BackupDir)
        Catch ex As GenericControllerException
          MessageBox.Show(ex.Message.ToString, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information)
        End Try

Newbe2009-10-14 07:46:57

Comments

  • Hi ,
    File System on Real Controller is not same as on PC( Windows)

    You need to mention the Backup directory name. e.g "MyBackup"

     

    now use this

    BackupDir="ctrl:(BACKUP)$/MyBackup"
    Regards
    Saleem Javed



  • Thank you for the response but that just creates the backup on the controller in the BACKUP folder.  I want the backup to be created on my PC running my PC SDK application.  so I have a folder on the root of my PC's hard drive called BACKUP and I want to create my backup of the controller in that folder so I would think the code should be:

    BackupDir = "ctrl:c:/BACKUP/NewBackup"
    controller.Backup(BackupDir)

    which would cause the folder NewBackup to be created in the folder BACKUP and all the controllers backup information would go in that folder?  right?

    Newbe2009-10-14 07:47:10
  • When you create a backup on the real controller using the Controller.Backup(path) function, it stores the backup in the folder you gave as location relative to the Controller.FileSystem.RemoteDirectory folder.










     

    Example: (Say that the RemoteDirectory is set to the HOME folder on the controller)

         Controller.Backup("TestBackup")

    This will create a backup and stores it on the controller in the HOME/TestBackup folder.

     

    What you could do is:

    1) Create a backup on the controller using Controller.Backup(string path)

    2) Wait until backup is completed using Controller.BackupInProgress property

    3) Send the folder with backup to the desired location on your PC using Controller.FileSystem.GetDirectory(string remoteDirectory, string localDirectory).

    4) If necessary you can delete the backup from the controller using Controller.FileSystem.RemoveDirectory(string path)
  • thank you for the response...can you give a example of what the string for remoteDirectory and LocalDirectory would look like please?

  • Ok lets say we want to create a backup from the controller on our computer at C:Temp in a folder named BACKUP.


     

    1) Create a backup at the real controller using the Controller.Backup(string path) function:

    The RemoteDirectory property of Controller.FileSystem is set to the HOME folder of the controller ( "/hd0a/14M-51688/HOME" ) were 14M-51688 is the name of my controller. And the path you give to the Backup function is relative to the RemoteDirectory property, so:

     

    Controller.Backup("TestBackup");

    while (Controller.BackupInProgress) { }

     

    This will create the backup in the following folder "/hd0a/14M-51688/HOME/TestBackup".

     

    2) Copy the folder containing the backup from controller to computer:

    The remote directory is again relative to the RemoteDirectory so you can give the same folder as you gave to the Backup function.

     

    Controller.FileSystem.GetDirectory("TestBackup", "C:\Temp\BACKUP")

     

    This will copy the backup from the controller to the computer at C:TempBACKUP.

     

    You should add some checks to check if directories exist and else you should create them.
  • Thanks KSP I will give that a try today and post back my results image
  • Hello KSP,

    Wanted to let you know that the backup on the controller and then using
    the GetDirectory works fine.  The problem is that the RemoveDirectory
    does not work.

    Here is the code for the button_click:



    Dim BackupDir As String = "MyBackup"

    controller.Backup(BackupDir)



    Here is the code for the BackupCompleted Event:



    Dim BackupDir As String = "MyBackup"


    controller.FileSystem.RemoveDirectory(BackupDir)


    below is the error that I get.  I do have Mastership of the controller.  Any help that you or anybody else could offer would be great.

    image








  • Ok...I figured it out...so I needed to set the RemoteDirectory to the full path before I made the call to RemoveDirectory

    Example
    controller.FileSystem.RemoteDirectory() = "/hd0a/66-59720/HOME"
    controller.FileSystem.RemoveDirectory(BackupDir, True)

    This works fine on a real controller...image

  • scottdf93
    scottdf93 United Kingdom
    Hi,

    I am attempting to do the same thing but when ever i try and use the GetDirectory function I throws the exception;

    {"Operation is not valid due to the current state of the object."}

    Any idea what is causing this? Both remote and local directories are set correctly.
Sign In or Register to comment.