How to copy the whole folder using rsync ?

Hi,

I'm now using the following command :

rsync --verbose --rsh='ssh -p6298' IP:/backup/cpbackup/daily/*.tar.gz /backup/cpbackup/daily/

But this will only copy the *.tar.gz , may i know how to make the command to copy the whole IP:/backup/cpbackup/daily/ folder including files and folders ?

Thank you.
LVL 2
Shamsul KamalJunior TechAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TintinCommented:
rsync -av --rsh='ssh -p6298' IP:/backup/cpbackup/daily/*  /backup/cpbackup/daily/

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Hedley PhillipsOwnerCommented:
Drop the * off the end as when you terminate the source with / it will sync everything under that path

eg:

rsync -av --rsh='ssh -p6298' IP:/backup/cpbackup/daily/  /backup/cpbackup/daily/

whereas (note no slash after daily on the source)

rsync -av --rsh='ssh -p6298' IP:/backup/cpbackup/daily /backup/cpbackup/daily/

will copy the daily directory (and contents) from the source into the target and you would end up with:

backup/cpbackup/daily/daily/


As an additional note. If you want to exclude files or directories, use this:

rsync -avp --delete --exclude-from=exclude_file.txt

where exclude_file.txt has the format:

- *.txt
- *.doc
- */DIV*/*

The example above would exclude all .txt files, all .doc files and any directories under /div
 
ai_ja_naiCommented:
Don't forget z flag, to compress tranferred contents, or it will take ages
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Hedley PhillipsOwnerCommented:
While the -z switch can help, be careful where you use it.

With data that is already compressed, ie .zips or .gz's you could just be wasting CPU cycles and time and possibly even increasing the amount of data transferred.
TintinCommented:
Additionally, using the -z flag to transfer files across a gigabit link is wasteful and potentially slows the transfer down.
ai_ja_naiCommented:
Of course, transferring already compressed files with compression in useless.
But I belive that saving transfer time is always a good thing.
Why on gigabit should it be wasteful?
TintinCommented:
Compression of data requires time and CPU cycles.  On fast links, depending on the type of data, it can often be faster to not use compression.
ai_ja_naiCommented:
But doesn't this contribute to the general internet lag? Shouldn't we always try to send as little data as possible on a link?
TintinCommented:
If you have a link with plenty of capacity and you want to reduce transfer times and server load, then there's nothing wrong with uncompressed data.

Of course, it depends on many factors as to how beneficial or otherwise it will be.
ai_ja_naiCommented:
I understand
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.