ERASEFILES vs. ERASEFILES_SECONDARY
peter_mxtoolbox
Posts: 2
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"
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
Yes, ERASEFILES/ERASEFILES_SECONDARY will not proceed if the restore fails.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8