Backup log to disk='null' with copy_only

  • Good morning Experts,
    Can I use the below command? Is it safe?
    Backup log to disk='nul' with copy_only
    As i am using copy_only , it will not break the log chain, correct? And later, I can shrink this log file, correct?

  • It will not break the log chain (which I think is your goal), but it won't affect shrinking the log file.  In order to shrink the log file (not recommended) you need to have the log backed up (ie remove the copy_only).
    I do not recommend doing a backup to null though.  You will not be able to recover in the event of an emergency.

    What I would recommend (if you do need to shrink the log) is to do a tlog backup and then shrink the log file.  Shrinking the log file will affect performance of the system though both during and possibly after if the log needs to grow again.

    The above is all just my opinion on what you should do. 
    As with all advice you find on a random internet forum - you shouldn't blindly follow it.  Always test on a test server to see if there is negative side effects before making changes to live!
    I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.

  • bmg002 - Monday, November 6, 2017 2:45 PM

    It will not break the log chain (which I think is your goal), but it won't affect shrinking the log file.  In order to shrink the log file (not recommended) you need to have the log backed up (ie remove the copy_only).
    I do not recommend doing a backup to null though.  You will not be able to recover in the event of an emergency.

    What I would recommend (if you do need to shrink the log) is to do a tlog backup and then shrink the log file.  Shrinking the log file will affect performance of the system though both during and possibly after if the log needs to grow again.

    So, using "with copy_only" does not backup the tlog?

  • using "copy_only" makes a backup of the tlog but it does not do a truncate of the log when it completes.  According to Microsoft:
    opy-only log backups (full recovery model and bulk-logged recovery model only)

    A copy-only log backup preserves the existing log archive point and, therefore, does not affect the sequencing of regular log backups. Copy-only log backups are typically unnecessary. Instead, you can create a new routine log backup (using WITH NORECOVERY) and use that backup together with any previous log backups that are required for the restore sequence. However, a copy-only log backup can sometimes be useful for performing an online restore. For an example of this, see Example: Online Restore of a Read-Write File (Full Recovery Model).

    The transaction log is never truncated after a copy-only backup.

    https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/copy-only-backups-sql-server

    It does still do a backup of the tlog when running "BACKUP LOG".

    The above is all just my opinion on what you should do. 
    As with all advice you find on a random internet forum - you shouldn't blindly follow it.  Always test on a test server to see if there is negative side effects before making changes to live!
    I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.

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

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