I make webiste in joomla.

Quite often i have to transfer the webiste from testing server to main server.

Initially i copied the files to new server then again i had to chnage the directory permissions of the folders and it was taking to much time. Then someone told to use

tar -P

to preserve the permissions and it made my life easier with all permission preserved.

Now the another problem which i am facing is that . There are some scripts which generate their own files and folders. now they have read and write for the owner .

But when i change the server then those scripts don't keep thier ownership to those files which they have created so i have chnage chnage 100s of file permissions again

Is there any solution to keep the ownership of those scripts on new server

  • I guess you are using tar -cpf not tar -cPf the p must be in lower case to preserve permissions. – evildead Nov 26 '09 at 0:51

Do you have ssh access to both servers? If so you could try rsync with the '-a' option. Not sure if that will fix the problem but it's worth a try.

  • I have shell access and i have the VPS Is it possible to download the achieve file using rsync and then upload to new server and then again use rync to extract files to new server – John Nov 26 '09 at 2:06
  • You could do the sync straight from your production server. e.g. if you run this on the production server: rsync -az -e ssh user@source-server.com:/var/www/testingdir/ /var/www/productiondir/ (change user@source-server.com to your testing server) it will log into your testing server and pull down all the files/directories from the remote '/var/www/testingdir' and place them (overwriting everything) in the local '/var/www/productiondir' directory. Test this command out on some non-production servers first if you're not familiar with rsync! – phoenix8 Nov 26 '09 at 4:59
  • note that there is also a --delete option, but i strongly suggest not using it at all when syncing to a production server! (but if you do, make sure you have a complete recent backup!!!) – phoenix8 Nov 26 '09 at 5:07
  • thanks for that but the problem is sometimes when i have to restore form old saved backups , Is that possible with rsync – John Nov 26 '09 at 23:41
  • hmm, no, if the backup is in a tar file you'll have to use tar. as evildead said, when you are backing up files to a tar make sure you run tar with the -p switch (lowercase) – phoenix8 Dec 1 '09 at 1:18

If these scripts are generated on a user with the id (or better known as the login name) foo and the uid (which is the internal number representation of the login name) is 8080 eg. and you are using tar -p than on the new system the user must have the same uid on the new system as like on the testing system.

Check the uid to id mapping and change it accordingly to your testing system, than all things are the same on both server.

You can also create a seperate group and give read/write permissions in the group. Then put all your users wich needs read/write access to this files in that group.

Now you can recursivly change the groups on the webserver. Use chown -R :thegroup /path/to/webserver If both groups are the same on both machines, check the uid to id mapping too and change them to fit on both servers. Then you dont need to do the chown thing everytime.

To master this you have to get some knowledge what the difference between the id foo and the uid 8080 is exactly.

  • I have seen the scripts and their owner is nobody. is it safe that when i copy the website contents to new server then i change the owner of all files to the username of that webiste – John Nov 26 '09 at 2:07
  • that should be the normal way. But you have to take care that the process who is owned by the the user who starts apache needs probably write rights in some dirs too. So take care that apache user can do that. You can do by adding a seperate group and put the apache user in it. If you can give concrete Data it would be easier to explain exactly. Which user runs your apache process? and how is your group setup on the webserver? – evildead Nov 26 '09 at 12:08
  • I don't much about group and apache. All i know is that i have 2VPS. One is for testing and other is for live site. All i need to do is to migrate the whole public_html folder to new server with same ownership and permisiion. I make the user through cpanel so i go to /home/username/public_html and copy contents there. I was thinking to use chown all files and foldersunder public_html to that username so that all files can be edited Is that right – John Nov 26 '09 at 23:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy