You can run "chown -R <user>.<group> <target_directory>/" and "chmod -R <mode> <target_directory>/" as root to change all of the files in the target directory recursively.
To change the ownership of files, you need to be the root user.
One thing you could look at is something like:
Code:
tar -C /home/joessho/public_html/caps/ --owner=jackm --group=users --mode='ug=rw,o=r' -f - | su -c 'tar -C /home/jackm/public_html -xf- .'
An actual tarfile isn't created. A pipe is used to transfer the tarball from the first tar command to the second. This is a way to copy directory structures to another directory. The --owner, --group and --mode options allow you to change the ownership and permissions of the files as they are being archived. Those are the properties they will have when they are extracted. There are two other options dealing with replacing timestamps you can use as well.
You could apply other options such as --newer or -g timestampfile to replicate the files from the first dir to the second one. Using rsh or ssh on the RHS you can run a script to copy or replicate files from one computer to another, even across the internet.
Be sure you read the tar info manual before using this, and test if out. There may be more option you need. Pay attention to things such as the order that things are backed up. E.G. files or directories first, and whether you want files or directories things overwritten.
Even if you copy the files, and then change the permissions, you need to be careful. For example, you may need to change the mode of the files separately from the mode of the directories. The 'x' bit needs to be set on directories, but shouldn't be set for non-programs.
find dest_dir/ -type f -exec -chmod u=rw,o=r '{}' \;
find dest_dir/ -type d -exec -chmod u=rwx,o=rx '{}' \;
As you probably notice, one disadvantage to recursively changing the permissions of the destination directory is that you will be processing all of the files, not just the ones you copied over. What do you want to do if the same file exists on the destination? Overwrite the file? Keep the original? Or maybe copy the original and create a backup.
Good Luck!
---
note: I didn't test my example. Please test them yourself it you decide to use it.
For example, I don't know if tar will clear the 'x' bit in my example for directories, or just for files.