Problem with latest_all

This works:

EXECUTE master..sqlbackup '-SQL "RESTORE DATABASE [Henrik_UAT] 
FROM 
DISK = ''D:\Transfer\FULL_(local)_Henrik_*.sqb'',
, DISK = ''D:\Transfer\DIFF_(local)_Henrik_*.sqb''
WITH REPLACE,
PASSWORD = ''<secret>''"'

this produce an Error 507: No valid backup sets found from provided folder(s).

EXECUTE master..sqlbackup '-SQL "RESTORE DATABASE [Henrik_UAT] 
FROM 
DISK = ''D:\Transfer\FULL_(local)_Henrik_*.sqb'',
, DISK = ''D:\Transfer\DIFF_(local)_Henrik_*.sqb'' latest_all
WITH REPLACE,
PASSWORD = ''<secret>''"'

The first read only the FULL and ignore the DIFF.

What is wrong ?
Tagged:

Best Answers

  • petey2petey2 Posts: 88 Silver 3
    edited May 14, 2021 5:48AM Answer ✓
    What was the original database name you are now trying to restore using the backup files?  

    In your second script,  SQL Backup will only scan the backup files made for the Henrik_UAT database.  If the backup files were for a different database, you need to use the SOURCE option e.g. if the files were for a database named Henrik_PROD


    EXECUTE master..sqlbackup '-SQL "RESTORE DATABASE [Henrik_UAT] 
    FROM DISK = ...  SOURCE = [Henrik_PROD] LATEST_ALL 
    WITH REPLACE, PASSWORD = ''<secret>''"


    Now SQL Backup will scan all backup files belonging to Henrik_PROD, and restore them to the latest possible state.

    Your first script (without the LATEST_ALL option) will only restore full database backups.  It also works without the SOURCE option because most likely all the files matching the search pattern belonged to the same database.
    SQL Backup - beyond compression
  • HenrikFFMHenrikFFM Posts: 4 New member
    Answer ✓
    Thank you very much. That works for me.
Sign In or Register to comment.