Backup Registry Hives


  1. Posts : 5,330
    Windows 11 Pro 64-bit
       #1

    Backup Registry Hives


    As many of us knows that latest version of Windows 10 won't backup registry hives which could be needed when Windows 10 won't boot because of registry errors.

    I have created batch script for backing up registry hives this batch script will create two folders at root of C: partition and stores copies of registry hives. The folder named Registry_Backups will contain newly created registry hives and previously created copies of registry hives, these previous backups will have OLD extension. The C:\Registry_Backups\RegOld folder contains previously created registry hive files with OLD extension. This batch script can be schedule to make backup copies of the registry hive files at any given time, i have setup a schedule to make sure my registry hives are backup at logon time.

    Execute the batch script with administrative privileges.

    Code:
    :: Created By FreeBooter
    @Echo Off & Cls
    Echo.
     
    Call :IsAdmin
     
    If Not Exist C:\Registry_Backups (md C:\Registry_Backups) Else (Goto :Skip)
    If Not Exist C:\Registry_Backups\RegOld (Md C:\Registry_Backups\RegOld) Else (Goto :Skip)
     
    :Skip
     
    if exist C:\Registry_Backups\DEFAULT.OLD move /Y C:\Registry_Backups\DEFAULT.OLD C:\Registry_Backups\RegOld
    if exist C:\Registry_Backups\SAM.OLD move /Y C:\Registry_Backups\SAM.OLD C:\Registry_Backups\RegOld
    if exist C:\Registry_Backups\SECURITY.OLD move /Y C:\Registry_Backups\SECURITY.OLD C:\Registry_Backups\RegOld
    if exist C:\Registry_Backups\SOFTWARE.OLD move /Y C:\Registry_Backups\SOFTWARE.OLD C:\Registry_Backups\RegOld
    if exist C:\Registry_Backups\SYSTEM.OLD move /Y C:\Registry_Backups\SYSTEM.OLD C:\Registry_Backups\RegOld
    if exist C:\Registry_Backups\NTUSER.OLD move /Y C:\Registry_Backups\NTUSER.OLD C:\Registry_Backups\RegOld
    
     
     
     
     
     
    If Exist C:\Registry_Backups\DEFAULT Ren C:\Registry_Backups\DEFAULT DEFAULT.OLD 2>&1 > Nul
    If Exist C:\Registry_Backups\SAM Ren C:\Registry_Backups\SAM  SAM.OLD 2>&1 > Nul
    If Exist C:\Registry_Backups\SECURITY Ren C:\Registry_Backups\SECURITY SECURITY.OLD 2>&1 > Nul
    If Exist C:\Registry_Backups\SOFTWARE Ren C:\Registry_Backups\SOFTWARE SOFTWARE.OLD 2>&1 > Nul
    If Exist C:\Registry_Backups\SYSTEM Ren C:\Registry_Backups\SYSTEM SYSTEM.OLD 2>&1 > Nul
    If Exist C:\Registry_Backups\NTUSER.DAT Ren C:\Registry_Backups\NTUSER.DAT NTUSER.OLD 2>&1 > Nul
     
     
     
    If %Errorlevel% GTR 0 (
    @Echo Set oWshShell = WScript.CreateObject^("WScript.Shell"^) > %Tmp%\Popup.vbs
    @Echo oWshShell.Popup "Error Backing Registry Hives" , 15, "Registry Hive Backup Error", 0     >> %Tmp%\Popup.vbs
    Wscript %Tmp%\Popup.vbs
    )
     
    If Exist "%Tmp%\Popup.vbs" Del %Tmp%\Popup.vbs >nul
     
     
     
    REG SAVE HKU\.DEFAULT C:\Registry_Backups\DEFAULT
    REG SAVE HKLM\SAM C:\Registry_Backups\SAM
    REG SAVE HKLM\SECURITY C:\Registry_Backups\SECURITY
    REG SAVE HKLM\SOFTWARE C:\Registry_Backups\SOFTWARE
    REG SAVE HKLM\SYSTEM C:\Registry_Backups\SYSTEM
    REG SAVE HKCU C:\Registry_Backups\NTUSER.DAT
     
     
    :IsAdmin
    Reg query "HKU\S-1-5-19\Environment"
    If Not %ERRORLEVEL% EQU 0 (
     Cls & Mode CON  LINES=5 COLS=48 & Color 0C & Title - WARNING -
     Echo.
     Echo.
     Echo  YOU MUST HAVE ADMINISTRATOR RIGHTS TO CONTINUE
     Pause >Nul & Exit
    )
    Cls
    Goto :EOF

    Please copy/paste batch scripts codes to Notepad and save it as RegBackup.bat.
      My Computer


  2. Posts : 42,991
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #2

    Reported here:
    Windows 10 bug prevents Registry backup creation - gHacks Tech News

    - and known here on tenforums well before that.

    Some may like to use a 3rd party tool such as Tweaking.com's
    Registry Backup

    This backs up more dat files, and offers a number of settings including 1 click scheduled task creation, as well as registry restoration.

    Backup Registry Hives-snap-2019-01-13-20.34.41.png
      My Computers


  3. Posts : 5,452
    Windows 11 Home
       #3

    And how do restore the backup, if you can not boot? Is it not simpler to create a system backup instead?
      My Computer


  4. Posts : 42,991
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #4

    That's documented on the internet quite widely, making use of the now non-functional Regback feature. Requires a live boot disk of course.

    I've used it a couple of times on tenforums; exclusively for the case where a user's registry is suddenly corrupted, PC unbootable, System Restore unavailable, and user has no disk images.

    Example: (these include this basic copy from backup and more)
    Restore Windows 10 Registry from Backup using Command Prompt TheITBros
    5 Ways To Backup and Restore the Windows Registry or Selected Hives • Raymond.CC
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 22:42.
Find Us




Windows 10 Forums