Script Center > Scripting Forums > The Official Scripting Guys Forum! > Backup script for laptops to a USB drive
Ask a questionAsk a question
 

AnswerBackup script for laptops to a USB drive

  • Wednesday, November 19, 2008 11:46 AMjacklindsay Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Guys, 

    im not too sure if this is even possible but any help or advice given would be greatly appreciated.

    the company i work for has lots of laptops with not so careful reps using them.  once in a while we get a call about some technical problem with the laptop and it needs to be sent back to us.  sometimes they need a quick backup of files, and this is where we would like a script to help make our lives easier.

    i read that you can give a USB flash drive a fixed drive letter, but we have a couple of usb drives, which we would like to have the same drive letter on all of them (i know that if this is possible, multiple flashdrives couldn't be used at the same time).

    i need the script to basically copy whats on Desktop and My Documents to a flash drive that is connected.

    i was also wondering if it can be written to also back up emails, address books, and email account settings.  we use outlook express for the reps, and i know that there are a couple of folders about in Documents and Settings which hold these.

    Thanks in advance for any hope and advice

    Jack

Answers

  • Wednesday, November 19, 2008 3:21 PMJRussell97 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Here is a script and a command file that I use to move user profiles from one computer to another.  It displays an input box for the source and then one for the destination.  Once this information is entered it will run XCopy to copy the files.

    Here is the script.

    '*************************************************************************************
    '* This script Copies a profile from the local c: drive to a backup location so it can be
    '* restored on a different PC or a new image of the existing PC.
    '*************************************************************************************

    '*************************************************************************************
    '*  Find Source Profile Location
    '*************************************************************************************

    Dim varInText
    BlankLine = " "
    quit = "N"
    Do while quit = "N"
        varInText = InputBox ("Enter the complete path of the Source folder to Migrate.", "Select Source Folder to Migrate:")
        If varInText = "" Then
     WScript.echo "Script terminated by Operator"
     Wscript.quit
        Else
          Quit = "Y"
        End if
    '        Set objFSO = CreateObject("Scripting.FileSystemObject")
    '
    '        If objFSO.FileExists(varInText) Then
    '            Set objFolder = objFSO.GetFile(varInText)
    '     quit = "Y"
    '        Else
    '            Wscript.Echo "File " & varInText & " does not exist."
    '        End If
    '    End if
       


    '*************************************************************************************
    '*  Find Target Profile Location
    '*************************************************************************************
    Dim varOutText

    quit = "N"
    Do while quit = "N"
        varOutText = Inputbox ("Enter the complete path of the Target Location.", "Select Target Folder to Copy to:")
        If varInText = "" Then
     WScript.echo "Script terminated by Operator"
     Wscript.quit
        else
     Quit = "Y"
        End if
       
    Loop

    '*************************************************************************************
    '* Display file values and make sure the operator wants to proceed
    '*************************************************************************************
    quit = "N"
    Do while quit = "N"
        answer = Inputbox ("Input profile is " & varInText & vbcrlf & vbcrlf & _
                           "Target folder is " & varOutText & vbcrlf & vbcrlf & _
                           "Proceed with Migration YES\NO", _
                           "Verify files to be processed:", "YES")

        If answer = "" or ucase(answer) = "NO" Then
     WScript.echo "Script terminated by Operator"
     Wscript.quit
        else
            If ucase(answer) = "YES" Then
                quit = "Y"
            Else
                Wscript.Echo "PLease enter YES or NO"
            End If
        End if
       
    Loop



    '*************************************************************************************
    '* Copy profile
    '*************************************************************************************

    CopyCmd = "H:\ProfileCopy.cmd " & chr(34) & VarInText & chr(34) & " " & chr(34) & VarOutText & chr(34)


    Set WshShell = WScript.CreateObject("WScript.Shell")

        WshShell.Run(CopyCmd)


    '*************************************************************************************
    '* Finished
    '*************************************************************************************

    WScript.Quit



    And here is the Command file.

    xcopy %1 %2 /E /C /H /K /Y


    Change H:\ProfileCopy.cmd  in the script to reflect the location and name of the command file.


    Put the full path of the directory that you want to copy in the source input box. (EX: c:\documents and settings\jrussell) and the full path to the place you want to store the information. (EX: F:\Profile Store\jrussell).

    When you want to restore it just reverse the source and destination inputs.  I have found that this will get everything in the users profile which usually includes their desktop and documents folder.

    Since you are specifying the drive letters you do not need to have a fixed drive lr=etter for the USB.

    I hope this will help you.



     

All Replies

  • Wednesday, November 19, 2008 3:21 PMJRussell97 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Here is a script and a command file that I use to move user profiles from one computer to another.  It displays an input box for the source and then one for the destination.  Once this information is entered it will run XCopy to copy the files.

    Here is the script.

    '*************************************************************************************
    '* This script Copies a profile from the local c: drive to a backup location so it can be
    '* restored on a different PC or a new image of the existing PC.
    '*************************************************************************************

    '*************************************************************************************
    '*  Find Source Profile Location
    '*************************************************************************************

    Dim varInText
    BlankLine = " "
    quit = "N"
    Do while quit = "N"
        varInText = InputBox ("Enter the complete path of the Source folder to Migrate.", "Select Source Folder to Migrate:")
        If varInText = "" Then
     WScript.echo "Script terminated by Operator"
     Wscript.quit
        Else
          Quit = "Y"
        End if
    '        Set objFSO = CreateObject("Scripting.FileSystemObject")
    '
    '        If objFSO.FileExists(varInText) Then
    '            Set objFolder = objFSO.GetFile(varInText)
    '     quit = "Y"
    '        Else
    '            Wscript.Echo "File " & varInText & " does not exist."
    '        End If
    '    End if
       


    '*************************************************************************************
    '*  Find Target Profile Location
    '*************************************************************************************
    Dim varOutText

    quit = "N"
    Do while quit = "N"
        varOutText = Inputbox ("Enter the complete path of the Target Location.", "Select Target Folder to Copy to:")
        If varInText = "" Then
     WScript.echo "Script terminated by Operator"
     Wscript.quit
        else
     Quit = "Y"
        End if
       
    Loop

    '*************************************************************************************
    '* Display file values and make sure the operator wants to proceed
    '*************************************************************************************
    quit = "N"
    Do while quit = "N"
        answer = Inputbox ("Input profile is " & varInText & vbcrlf & vbcrlf & _
                           "Target folder is " & varOutText & vbcrlf & vbcrlf & _
                           "Proceed with Migration YES\NO", _
                           "Verify files to be processed:", "YES")

        If answer = "" or ucase(answer) = "NO" Then
     WScript.echo "Script terminated by Operator"
     Wscript.quit
        else
            If ucase(answer) = "YES" Then
                quit = "Y"
            Else
                Wscript.Echo "PLease enter YES or NO"
            End If
        End if
       
    Loop



    '*************************************************************************************
    '* Copy profile
    '*************************************************************************************

    CopyCmd = "H:\ProfileCopy.cmd " & chr(34) & VarInText & chr(34) & " " & chr(34) & VarOutText & chr(34)


    Set WshShell = WScript.CreateObject("WScript.Shell")

        WshShell.Run(CopyCmd)


    '*************************************************************************************
    '* Finished
    '*************************************************************************************

    WScript.Quit



    And here is the Command file.

    xcopy %1 %2 /E /C /H /K /Y


    Change H:\ProfileCopy.cmd  in the script to reflect the location and name of the command file.


    Put the full path of the directory that you want to copy in the source input box. (EX: c:\documents and settings\jrussell) and the full path to the place you want to store the information. (EX: F:\Profile Store\jrussell).

    When you want to restore it just reverse the source and destination inputs.  I have found that this will get everything in the users profile which usually includes their desktop and documents folder.

    Since you are specifying the drive letters you do not need to have a fixed drive lr=etter for the USB.

    I hope this will help you.



     

  • Wednesday, November 19, 2008 8:43 PMMarcus Farmer Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I had a similar situation except I had to visit and backup computers at various clients' locations.  I wrote an HTA to provide a quick GUI for the use of a VBScript that performs an ntbackup of the local computer.  Place these 3 files on the root of an external hard drive - I use a 500 GB SATA drive in a USB enclosure.  Each computer's backup is placed in a named folder on the root of the drive.  The HTA takes care of disk space reporting as well as information on the age and size of each computer's backup file.  You can use the HTA to update what will be backed up (alter its BKS file) for each computer individually.  My VBScript, HTA and an autorun.inf file have been uploaded to scriptinganswers.com scripting repository if you want to check them out.

    http://www.scriptinganswers.com/forum2/uploads/162/backup.zip
  • Monday, January 05, 2009 10:29 PMCarmando Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Awesome.  Good job.  I think i will be using this on mine and my wife laptops.  Thanks.

    Mike C.