• Need to auto-sync data from usb pen

    Author
    Topic
    #455563

    Hi

    I currently use Keepass to maintain my passwords and Wiki-on-a-Stick for general notes. The wiki file and the Keepass datafile both reside on my main computer and I also like to have them on my usb pendrive. At the moment I have to remember which copy of the data is the most up-to-date. What I want to do is to have these 2 files sync automatically each time the pendrive is mounted on my computer, i.e. check which is the most recent file and copy it whichever way its needed.

    I can’t see any backup software that does just this (don’t expect to) so plan to write something myself. Has anyone else done this? Can anyone suggest the best place to start, e.g. Robocopy, Autoit or something else? I am a reasonably competent programmer (primarily VBA).

    (Please feel free to move this post to a more suitable forum if necessary.)

    Regards
    David

    Viewing 0 reply threads
    Author
    Replies
    • #1134606

      I used a BATch file with a double ROBOCOPY, one for each direction, but it’s on a USB Flash Drive at the office…

      Later… No it was upstairs.

      @echo off
      
      :: run ONLY on MyPcName
      
      if /i not "%computername%"=="MyPcName" (
        echo %~n0: running on %computername%, not on MyPcName
        ping -n 4 127.0.0.1 > nul
        exit
      )
      
      setlocal
      
      :: robocopy BOTH ways so that files are up-to-date on both PC and UFD
      
      :: common parameters
      set files="Files to be Copied*.*"
      set parms=/xo /np /r:0 /w:0
      cls
      
      :: a) from HD to UFD
      set source=c:target
      :: %~d0 always gives the drive letter of where this BATch file is located
      set target=%~d0UFDdir
      robocopy %source% %target% %files% %parms%
      ping -n 3 127.0.0.1> nul
      cls
      
      ::  from UFD to HD
      
      set source=%~d0UFDdir
      set target=c:target
      robocopy %source% %target% %files% %parms%
      ping -n 3 127.0.0.1> nul
      
      :: ask whether to dismount the USB Flash Drive
      set /p answer="Do you want to dismount the USB Flash Drive on %~d0?  "
      if /i not "%answer%"=="y" endlocal & exit
      
      :: do the dismount
      endlocal & rundll32.exe shell32.dll,Control_RunDLL hotplug.dll & exit

      Obviously you will have to rework it, since I was just syncing files from a directory on the UFD to one on the C: drive…

      BATcher

      Plethora means a lot to me.

      • #1134803

        Very many thanks, BATcher. This is far more than I expected. I’ll be amending and trying it out over the next few days.

        Regards
        David

      • #1134872

        Hi BATcher

        Many thanks for the bat script. It runs a dream although I found out I needed to remove the words ‘Files to be copied’ out of the set files line for it to work.

        Can I ask you for 2 additional bits of help. Firstly, what do you put in your autorun.inf file to start the process automatically? Second, in the last line (endlocal) what would I put to have the batch file run a further program, e.g. PStart.exe?

        Regards
        David

        • #1134902

          With regard to your two questions:

          a) I’ve never been very successful in getting a BATch file to run automatically on the insertion of a USB Flash Drive, and so I just start it from Windows Explorer. searching Google Groups gave me this about CD insertion (similar matter).

          the concatenation of the final commands is not necessary, and you can split them onto separate lines, and insert your PStart.exe in an appropriate location

          BATcher

          Plethora means a lot to me.

    Viewing 0 reply threads
    Reply To: Need to auto-sync data from usb pen

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: