Automated sql server restore

  • Hi,

    I am planning to automate restoration process of all db's on test server with latest full, diff and log backups. Backup process is automated: means Full backup every 15 days, diff. backup every day at 10AM, log backup every half an hour.

    Full backup path -- Eg: c:\fullbackup\dec\fullbackup_dmmyyyy.bak,

    Diff backup path -- Eg: D:\Difbackup\Dec\Diffbackup_ddmmyyyy.bak,

    Log backup path -- Eg: E:\Logbackup\Dec\Logbackup_ddmmyyyy.bak

    Please help me to automate the db restoration through query. Thanks In Advance.

    Regards,

  • The basic statements you need are the following:

    restore database xy from disk = 'g: c:\fullbackup\dec\fullbackup_dmmyyyy.bak' with norecovery

    restore database xy from disk = 'g: D:\Difbackup\Dec\Diffbackup_ddmmyyyy.bak' with norecovery

    restore database xy from disk = 'E:\Logbackup\Dec\Logbackup_ddmmyyyy.bak' with recovery

    Take care with the log backups. If there is more than 1 log backup after the differential backup, you need to restore ALL the log backups, one after another.

    Each log backup has to be restored using "with norecovery", for the last restore use "with recovery".

    Take a look at books online to get familiar with RESTORE DATABASE statement and its options.

  • sorry wrong post

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply