Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have installed a cms (modx) on a webserver running CentOS 5 and Apache 2.2. Now there is a new version and I would like to update it. The instructions in the modx-wiki suggest to overwrite the existing files.

I've downloaded a .zip-File and extracted it. The existing installation sits in html/cms/. The new files sit in html/modx-2.1.1-pl/. I access the server through an ssh connection.

How do I move the new files to html/cms/ while overwriting existing files and preserving files that are not part of the installation files? I already tried the mv-command and read that rsync or cp might be suitable.

When I tried mv -ivt cms/ modx-2.1.1-pl/* it didn't work out. Subdirectories of modx-2.1.1-pl/ haven't been moved.

How to do it right?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

First, make a backup of the existing files, just in case.

tar czf modx-old.tar.gz html/cms

Then use cp to copy the new files into place. You can't use mv here because it would just skip existing directories instead of recursing into them. But cp will do a deep copy, overwriting any existing file in the destination.

cd html/modx-2.1.1-pl/ && cp -Rpf . ../html/cms/

With GNU cp, you can add -l to create hard links instead of copying.

Finally you can remove the modx-2.1.1-pl directory.

share|improve this answer
1  
Actually cp would work just fine for this. cp -r html/modx-2.1.1-p1/. html/cms/ (-a instead of -r would probably be even better though). –  Patrick Jun 20 '11 at 23:38
    
@Patrick: Ah, you're right. mv isn't suitable, but cp is. –  Gilles Jun 20 '11 at 23:44
    
Thank you for your help @Gilles and @Peter. It worked for me with cp -Rpv html/modx-2.1.1-pl/* html/cms/. I used the * because I needed all the files under modx-2.1.1-pl under cms. –  haldgreen Jun 21 '11 at 16:59
add comment

You just have the order of the arguments wrong. The usage of the mv command is mv source dest. If you want to move everything under modx-2.1.1-pl to cms, you should do mv modx-2.1.1-pl/* cms/. It may actually be better to use cp instead of mv, in which case the syntax would be cp -r modx-2.1.10pl/* cms/.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.