Bug 801873 - Behavior of "cp --backup" changed, not backing up individual files
Summary: Behavior of "cp --backup" changed, not backing up individual files
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: coreutils
Version: 5.7
Hardware: i386
OS: Linux
urgent
medium
Target Milestone: rc
: ---
Assignee: Ondrej Vasik
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks: 803356
TreeView+ depends on / blocked
 
Reported: 2012-03-09 17:40 UTC by Tyler Aviss
Modified: 2018-11-29 21:22 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
An incomplete fix for behavior of the "mv --backup" command, that was released with the RHBA-2011:1074 errata advisory, caused the "cp --backup" command to work incorrectly. When used with a directory as a source argument, the "cp --backup" command did not backup individual files within the directory but whole directory. This update corrects this problem and the "--backup" feature of the "cp" utility now works as intended again.
Clone Of:
Environment:
Last Closed: 2013-09-23 11:09:37 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Patch for fixing broken backup for directory argument (515 bytes, patch)
2012-03-14 10:18 UTC, Ondrej Vasik
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 80773 0 None None None Never

Description Tyler Aviss 2012-03-09 17:40:21 UTC
Description of problem:

With the previous version of "cp" (coreutils 5.97-23.el5_6.4), the behavior of the --backup against a directory was to take any existing files in the directory, rename with a backup suffix, and insert the new file With the newer coreutils (5.97-34.el5), the behavior is now that the destination directory is renamed with the backup suffix, and a new directory is created containing only files being copied in.

The version of "cp" is still 5.97, so I believe this is a bug rather than intended behavior, possible caused by other cp-related bugfixes.

Version-Release number of selected component (if applicable):
coreutils 5.97-23.el5_6.4


How reproducible: Always


Example, with structure
  /dest/files/somefile.txt 5c9597f3c8245907ea71a89d9d39d08e
  /dest/files/anotherfile.txt b8694d827c0f13f22ed3bc610c19ec15
  /source/files/somefile.txt c576ec4297a7bdacc878e0061192441e

Steps to Reproduce:
From the "/source" directory, the following command would be run: 
  cp --backup --suffix=_old files /dest/

  
Actual results:
  /dest/files_old/somefile.txt 5c9597f3c8245907ea71a89d9d39d08e
  /dest/files_old/anotherfile.txt b8694d827c0f13f22ed3bc610c19ec15
  /dest/files/somefile.txt c576ec4297a7bdacc878e0061192441e 

Expected results:
  /dest/files/somefile.txt_old 5c9597f3c8245907ea71a89d9d39d08e
  /dest/files/somefile.txt c576ec4297a7bdacc878e0061192441e
  /dest/files/anotherfile.txt b8694d827c0f13f22ed3bc610c19ec15

Additional info:
  RedHat: See also Case 00611703

Comment 1 Ondrej Vasik 2012-03-09 18:59:01 UTC
Thanks for report, confirmed (of course with -r option added). RHEL-6 cp behaves the expected way, so something probably went wrong in RHEL-5 update. I suspect the fix for #627285 (coreutils-5.97-mv-backupdirs.patch) .

Comment 2 Ondrej Vasik 2012-03-14 10:18:27 UTC
Created attachment 569951 [details]
Patch for fixing broken backup for directory argument

Attached patch should fix this issue.

Comment 7 Miroslav Svoboda 2012-03-15 16:23:45 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
An incomplete fix for behavior of the "mv --backup" command, that was released with the RHBA-2011:1074 errata advisory, caused the "cp --backup" command to work incorrectly. When used with a directory as a source argument, the "cp --backup" command did not backup individual files within the directory but whole directory. This update corrects this problem and the "--backup" feature of the "cp" utility now works as intended again.


Note You need to log in before you can comment on or make changes to this bug.