Bug #36402 Backup command too restrictive for backup image file. Need overwrite capability
Submitted: 29 Apr 2008 15:09 Modified: 22 Feb 2010 20:57
Reporter: Chuck Bell Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Backup Severity:S4 (Feature request)
Version:6.0.5 OS:Any
Assigned to: Thava Alagu CPU Architecture:Any

[29 Apr 2008 15:09] Chuck Bell
Description:
The backup command currently throws an error if the targe backup image file exists. This is a good protection for accidentaly overwrites, but there needs to be a way to tell the backup command to intentionally overwrite.

 

How to repeat:
Run the same backup command twice. Result: error on second run.

Suggested fix:
Add a parameter to the backup command that allows users to overwrite the backup image file. Suggested syntax can resemble:

BACKUP DATABASE xyz TO 'xyz.bak' IGNORE_OVERWRITE_ERROR;

In this case, the error must be changed to a warning and recorded for the user to inspect after the command. Sort of 'I told you so...' reminder.
[29 Apr 2008 16:37] Sveta Smirnova
Thank you for the report.

Verified as described.
[30 Sep 2009 12:21] Thava Alagu
Suggested Extension to the existing syntax :

BACKUP {DATABASE | SCHEMA}
    { * | db_name [, db_name] ... }
    TO 'image_file_name'
    [WITH COMPRESSION [COMPRESSION_ALGORITHM [=] algorithm_name]]
    [OVERWRITE] 

Note that the restore command also takes the option OVERWRITE at the end.
[15 Oct 2009 1:49] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/86891

2881 Thava Alagu	2009-10-15
      BUG#36402 - Backup needs option to overwrite backup image
      
      The backup sql command now takes additional option "OVERWRITE" 
      to overwrite backup image file even if one exists with the same name.
[21 Oct 2009 12:19] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/87627

2880 Thava Alagu	2009-10-21
      BUG#36402 - Backup needs option to overwrite backup image
      
           The backup sql command now takes additional option "OVERWRITE"
           to overwrite backup image file even if one exists with the same name.
[21 Oct 2009 12:28] Rafal Somla
Good to push.
[21 Oct 2009 12:44] Thava Alagu
Pushed the fix into mysql-6.0-backup tree. 

Note to the documentation team: 
    The syntax extension for backup need to be updated as suggested earlier:

BACKUP {DATABASE | SCHEMA}
    { * | db_name [, db_name] ... }
    TO 'image_file_name'
    [WITH COMPRESSION [COMPRESSION_ALGORITHM [=] algorithm_name]]
    [OVERWRITE]
[20 Feb 2010 9:19] Bugs System
Pushed into 6.0.14-alpha (revid:ingo.struewing@sun.com-20100218152520-s4v1ld76bif06eqn) (version source revid:ingo.struewing@sun.com-20100119103538-wtp5alpz4p2jayl5) (merge vers: 6.0.14-alpha) (pib:16)
[22 Feb 2010 20:57] Paul DuBois
Noted in 6.0.14 changelog.

BACKUP DATABASE now has an OVERWRITE option that enables you to 
overwrite an existing backup image file. Without this option, the
behavior is the same as before: If the named image file already
exists, the statement fails with an error.  

Also updated BACKUP DATABASE section.