Page 1 of 1

How to untar and overwrite existing files

Posted: Tue Jul 17, 2007 11:47 pm
by cnymike
What is the proper commands to untar and overwrite files within a directory?

When I go to my cmsms installation root and upload the tar.gz file and then issue the command

Code: Select all

tar -zxvf cmsmadesimple-1.1.tar.gz
I end up with a new directory named "cmsmadesimple-1.1" in which are the untared files. but I don't want to create a new directory, I want the tar file to expand and overwrite the existing files. what am I doing wrong?

I am trying to "fix" an upgrade problem I'm having moving from 1.0.8 to 1.1

I had tried to simply "move" the unzipped files over my existing installation but this resulted in a fatal error which I have another thread on. I'm trying to rectify that by reinstalling over everything. The problem with manually overwriting each file was that when trying to overwrite a directory, i keep getting an error from my ftp client (cyberduck) that the directory is not empty and cannot be renamed.

Re: How to untar and overwrite existing files

Posted: Wed Jul 18, 2007 1:33 pm
by Pierre M.
Hello,

here is an ugly hack, NO WARRANTY, use it only if you understand it :

Code: Select all

mv cmsmsfolder cmsmsfolder.old
tar -zxf cmsms-1.1.tar.gz
mv cmsms-1.1 cmsmsfolder
tar -zcf my.tar.gz cmsmsfolder
rm -rf cmsmsfolder
mv cmsmsfolder.old cmsmsfolder
tar -zxf my.tar.gz (should expand overwriting cmsmsfolder)
Pierre M.

Re: How to untar and overwrite existing files

Posted: Wed Jul 18, 2007 1:35 pm
by calguy1000
Here's some simpler commands.

This WILL overwrite all of your files as it expands the cmsmadesimple-1.1.tar.gz directory into tar first and then copies the files overtop of your existing ones.

Code: Select all

cd /tmp
tar zxvf cmsmadesimple-1.1.tar.gz
cd cmsmadesimple-1.1
tar cf - . | ( cd <my installation directory> && tar xvf - )
Again, no warantees implied or expressed, use at your own risk.

Re: How to untar and overwrite existing files

Posted: Wed Jul 18, 2007 1:45 pm
by cnymike
Thanks guys. Torty, in this thread http://forum.cmsmadesimple.org/index.ph ... 566.0.html offered a suggestion and here is what I did...

I uploaded the cmsmadesimple-1.1 tar.gz file into my public_html directory.
I issued this command to untar it

Code: Select all

tar -zxvf cmsmadesimple-1.1.tar.gz
After untarring the file, i used the following command....

Code: Select all

cp -R cmsmadesimple-1.1/* stjameschurch
This recursively copied and overwrote all the files in the installation I was trying to upgrade.

I'm not much of  Unix or terminal kind of guy so this was hard for me to grasp but it seemed to work, my installation is back up and running with no more fatal errors. Yeah!