Kaseya Community

Workstation's user data - script backup

This question has suggested answer(s)

Hi, I have this batch file that copies files from users' My Docs to a file server. The client doesn't want to redirect this folder so this is how we backup their data.

Set /p Dest=<C:\kworking\utilities\Destination.txt
SET /p Logged=<c:\kworking\loggeduser.txt

SET Source="%USERPROFILE%\My Documents"
SET Target="\\%Dest%\backups$\UserData\%computername%\%Logged%\My Documents"

robocopy %Source% %Target% /MIR /XA:SH /R:5 /W:5 /NP /LOG:"c:\kworking\UserData.log"

This piece of code works fine as long as there is a user logged in. Getting the last logged user is not a problem but its getting that user's User Profile directory is. Very badly need some advice.

 

Thanks.

 

Andrew

All Replies
  • I use something very similar to back up the my docs, desktop (because people like to save documents on the desktop for some reason) and %userprofile%\Application Data\Microsoft\Outlook\ (because Outlook autocomplete is used as an address book/contacts list far too often) and just schedule the backup to run when I know the user will be logged in (usually mid-day or something similar).  It run every day so if the user is not logged in it's usually because the they're not in that day and therefore there is nothing new to add to the previous day's backup.

    The only other way I can think of at the moment is to trigger an procedure to run on login to create a text file or new environment variable etc on the workstation, or a custom audit field within Kaseya, with the user profile path in it so that you can look that up if user not logged in?

  • use LogEvent (intType,strMessage) in a logon script to write to the application log and then use the error log monitoring within Kaseya to monitor for that specific event and when it gets it trip your backup script from within Kaseya.  See the following MS KB Article for more info on the LogEvent command from within WSH -- support.microsoft.com/.../257541

  • Thanks for the suggestions. I have couple of options in mind and i'll include Tom's suggestion if in case.

    1. Take Rich's suggestion for a text file during logon.

    2. and i also thought of using psgetsid and get the ProfileImagePath from the Registry - tested this and so far its working on my test machine but not sure if its efficient for portability.

    Thanks Again.

  • Something else I've used previously (although not for my backup) that might work for you is create a procedure like the following:

    If user logged in

      do you stuff

    else

      schedule yourself to run again in x mins/hours.