• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 789
  • Last Modified:

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.
0
smksa
Asked:
smksa
  • 4
  • 4
  • 2
1 Solution
 
TintinCommented:
rsync -av --rsh='ssh -p6298' IP:/backup/cpbackup/daily/*  /backup/cpbackup/daily/
0
 
Hedley PhillipsCommented:
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
 
0
 
ai_ja_naiCommented:
Don't forget z flag, to compress tranferred contents, or it will take ages
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Hedley PhillipsCommented:
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.
0
 
TintinCommented:
Additionally, using the -z flag to transfer files across a gigabit link is wasteful and potentially slows the transfer down.
0
 
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?
0
 
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.
0
 
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?
0
 
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.
0
 
ai_ja_naiCommented:
I understand
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now