ERASEFILES vs. ERASEFILES_SECONDARY

peter_mxtoolboxpeter_mxtoolbox Posts: 2
edited August 2, 2015 9:28PM in SQL Backup Previous Versions
Quoting the documentation I have these two snippets. It appears they do the same thing. Is that correct? My current conclusion is that ERASEFILES_SECONDARY was added in 7.4 to give additional control over primary and secondary storage and so it duplicates the functionality of ERASEFILES as part of that? Also, I'm assuming that the ERASE will not proceed if the RESTORE fails. Is that correct?

ERASEFILES

The following example restores a transaction log backup to the pubs database and leaves it in a non-operational state, then moves the backup to C:processed_logs and deletes all transaction log backups of pubs other than the latest 10 from that folder:
"RESTORE LOG [pubs] FROM DISK = 'C:shipped_logspubsLOG_20120229_151009.sqb' WITH MOVETO = 'C:processed_logs', ERASEFILES = 10b, FILEOPTIONS = 1, NORECOVERY"

ERASEFILES_SECONDARY

The following example restores a transaction log backup to the pubs database and leaves it in a non-operational state, then moves the backup to C:processed_logs and deletes all transaction log backups of pubs over 12 hours old from that folder.
"RESTORE LOG [pubs] FROM DISK = 'C:shipped_logspubsLOG_20120229_151009.sqb' WITH MOVETO = 'C:processed_logs', ERASEFILES_SECONDARY = 12h, NORECOVERY"

Comments

  • peteypetey Posts: 2,358 New member
    In the case of restores, yes, ERASEFILES and ERASEFILES_SECONDARY will perform the same functionality, with the small difference being you do not need the FILEOPTIONS parameter for ERASEFILES_SECONDARY.

    Yes, ERASEFILES/ERASEFILES_SECONDARY will not proceed if the restore fails.
    Peter Yeoh
    SQL Backup Consultant Developer
    Associate, Yohz Software
    Beyond compression - SQL Backup goodies under the hood, updated for version 8
Sign In or Register to comment.