Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I run this on my CentOs box:

zip -r backup.zip /home/user/domains/example.com/public_html/

The command works ok as it should, but I have an annoying problem.

What I expect is when I open the zip to have one folder in it: public_html

Instead i have /home/user/domains/example.com/public_html/. Does anyone know how to prevent this?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

That looks like expected behavior, not strange behavior.

To get what you want, try this:

cd /home/user/domains/example.com
zip -r /srv/backups/example.com/backup.zip public_html
share|improve this answer
    
I run the above though a php script. Will what you suggest works with php exec ? –  user146526 Nov 28 '12 at 15:10
    
Change directories with PHP's chdir() call instead of the cd command, then. Otherwise it's the same. –  Michael Hampton Nov 28 '12 at 15:11
    
Excelent that works great! Thanks –  user146526 Nov 28 '12 at 15:28

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.