Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 418
  • Last Modified:

cp -r making partial copy

I'm using a cp command in the preinstall section of an RPM package.spec.  The rpm install is being exectued as root using scsudo.  The command looks like this:

cp -r $RPM_INSTALL_PREFIX0/base $RPM_INSTALL_PREFIX0/base_bak

The copy occurs.  The base_bak folder gets created, and a small portion of the folders/files under base get copied.  But most folders/files do not get copied.  The base folders and its contents are owned by a functionalId.

Does anyone uinderstand what's happening with this partial copy?

0
jkavx
Asked:
jkavx
  • 3
  • 3
  • 2
2 Solutions
 
Joseph GanSystem AdminCommented:
Try "cp -R" instead.
The difference between -R and -r is in the treatment by cp of file types other than regular and directory.  The original -r flag,
       for historic reasons, does not handle special files any differently from regular files, but always reads the file and copies  its
       contents.  This  has  obvious problems in the presence of special file types; for example, character devices, FIFOs, and sockets.
       The -R option is intended to recreate the file hierarchy and the -r option supports historical practice. It was anticipated  that
       a  future  version  of  this volume of IEEE Std 1003.1-2001 would deprecate the -r option, and for that reason, there has been no
       attempt to fix its behavior with respect to FIFOs or other file types where copying the file  is  clearly  wrong.  However,  some
       implementations  support -r with the same abilities as the -R defined in this volume of IEEE Std 1003.1-2001. To accommodate them
       as well as systems that do not, the differences between -r and -R are implementation-defined. Implementations may make them iden-
       tical. The -r option is marked obsolescent.
0
 
dbauermannCommented:
Doesn't occur any type of error?

Are you certain that the disk has space?
0
 
jkavxAuthor Commented:
No error.  The disk has space.  -R makes no difference.  If I do the copy myself, a full copy gets done.  Something about being done in the Rpm preinstall.
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
dbauermannCommented:
I suggest that you try log outputs to debug with this command:

cp -rv $RPM_INSTALL_PREFIX0/base $RPM_INSTALL_PREFIX0/base_bak 1>/tmp/out.log 2>/tmp/err.log

After this, look mainly err.log.
0
 
jkavxAuthor Commented:
A good idea, but err.log is empty and out.log just shows the command executed.
0
 
Joseph GanSystem AdminCommented:
So must be some permition problems.
0
 
dbauermannCommented:
If you don't have messages in err.log, I suspect that you have some bug in other part of the script... Could be?
0
 
jkavxAuthor Commented:
The problem was that the RPM uninstall step was removing everything in the folder so that the copy had nothing to copy.  To be exact, the uninstall step was leaving a couple of files behind, so these files were being correctly copied by the cp command.  

The issue now is why does the RPM uninstall step fail to uninstall everything, but that's a different question.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now