Copy files from one server to another with same permissions

copydirectoryfile-permissionsfiles

Im migrating to new server and i need to move few websites but i need to have same read/write permissions to new serves as they were on old server.

I don't need to keep group and owner id's same but it would be very hard if i have to go through all files on old server and check what are read/write permissions on folders and files than to set on new server.

My idea is to pack files copy to new server and unpack, but that somehow reset all permissions to default with 644 to files and 755 to folders. Can i somehow transfer files and folders with same permissions as they were on old server ?

Best Answer

Just use rsync:

rsync -avz /path/to/files newserver:/path_to_files 

This will recursively copy all files from /path/to/files on the old server to /path_to_files on the new server and keep permissions and owner informations. For more informations, see man rsync.