Forum Discussion

danbert73's avatar
danbert73
Level 3
8 years ago

Large restore challenge

I've been asked to complete a restore of multiple user drives, across multiple servers, over multiple years....I know...sounds like fun, right? Here are my challenges... 1. Generate a list of files ...
  • sdo's avatar
    sdo
    8 years ago


    cd to your working folder where your script resides...

    you should have two files already:
    list-of-source-clients.txt (contains 7 to 20 old server - i.e. backup client names)
    list-of-usernames.txt (contains 50 to 51 old usernames, partial strings, i.e. not full paths)


    ...then use this to generate a list of all MS-Windows type backup images in a two year date range:

    for each record in list-of-source-clients.txt
      extract clientname
      bpimagelist -idonly -d twoyearsagodatetime -e todaydatetime -pt MS-Windows -client $clientname > images.txt
      for each record in images.txt
        extract imagename
        extract imagedatetime
        for each record in list-of-usernames.txt
          extract username
          bplist -C $clientname -s $imagedatetime -e $imagedatetime -t 13 -I -PI -R 999 -nt_files *$username* >>files-$imagename.txt
        next
      next
    next

    ...then you would end up with a bunch of files named "file-*.txt" which contain a list of files to be restored from each image.
    The above was the easy part.


    Here comes the tricky part:

    dir /b files-*.txt > list-of-files.txt

    set targetserver = blahblah (i.e. the name of the server that restores will be written to)

    delete restore-commands.txt

    for each record in list-of-files.txt
      extract backupfilename
      extract imagename (from $backupfilename)
      extract clientname (from $imagename)
      extract imagectime (from $imagename)
      convert imagectime to imagedatetime

      set renamefile = restore-$imagename.txt

      for each record in $backupfilename
        extract sourcefilename
        set sourcelen = len( sourcefilename )

        set targetfilename = "F:\$imagename\" + Mid( $sourcefilename, 4, 999 )
        set targetlen = len( targetfilename )

        write $renamefile "rename $sourcelen $sourcefilename $targetlen $targetfilename"
      next


      write restore-commands.txt "bprestore -B -R $renamefile -C $clientname -s $imagedatetime -e $imagedatetime -f $sourcefilename -D $targetserver"
    next


    FYI - it is important that there is a one-to-one relationship between each file name entry in:
    -f sourcenames
    -R renamenames
    ...and so the above should achieve:
    - separate restore folder for each file in backups
    - restored folder structure maintainted underneath F:\imagenames\

    - and then you can run a tool to detect duplicate files and delete, so that only unique files are left.

    - and a list of restore commands in "restore-commands.txt"

    ...and so could pick the first one to test an actual restore.

    It may be possible to also capture and calculate the total size of what is to be restored. But I'll let you work out how to do that :)

    HTH.