Voytek wrote:
I want to compress a web tree to copy to another system whilst leaving the
original tree unaltered,
do I need to 1st tar it and then gzip it, or is there a single step
solution ?
Try:
su
cd /srv/www
tar cSf - . | ssh [EMAIL PROTECTED] '( cd /srv/www; tar xpf - )'
Noting that ssh compresses by default.
If you need more control over the compression then try:
su
cd /srv/www
tar cSf - . | \
gzip -c -n -9 | \
ssh -o 'Compression no' [EMAIL PROTECTED] \
'( cd /srv/www; gzip -d -c | tar xpf - )'
You'd need a pretty slow link to make bzip2 worth the effort
over gzip, but the syntax is almost the same.
"tar" also contains z and j flags which run gzip and bzip2 but
I really can't see why you'd prefer tar's gzip to ssh's gzip.
If you choose not to do the job as root (and there are good
reasons not to allow root to ssh to a box), then tar will
use the umask and permissions of the user you are logging
in as. So then you can do something like this if the destination
machine isn't too complex with ownership and permissions:
su -s /bin/bash apache
cd /srv/www/html
tar cSf - . | ssh [EMAIL PROTECTED] '( mkdir /home/me/html; cd /home/me/html;
umask 000; tar xpf - )'
ssh [EMAIL PROTECTED]
example> su
example# cd /home/me/
example# umask 000
example# mv -ru html /srv/www/html
example# find /srv/www/html -type f -user me -exec chmod u=rw,g=rw,o= {} \;
-exec chown apache:apache {} \;
example# find /srv/www/html -type d -user me -exec chmod u=rwx,g=rwx,o= {} \;
-exec chown apache:apache {} \;
example# exit
example> logout
Note that we are setting permissions and ownership to something reasonable,
not copying them from the tar file. If you need them to be exactly the
same then:
su
cd /srv/www
tar cSf - . | \
bzip2 -c -9 | \
ssh -o 'Compression no' [EMAIL PROTECTED] 'cat > srv-www.tar.bz2'
ssh example.edu.au
example> su
example# cd /srv/www
example# umask 000
example# tar xpjf /home/me/srv-www.tar.bz2
example# exit
example> rm /home/me/srv-www.tar.bz2
example> logout
but this requires enough disk space for the tar file on the destination machine.
Finally, you can probably do without the "S" flag. AARNet web sites have
a lot of sparse files so we can transfer those files for network performance
testing.
Best wishes,
Glen
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html