Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get folder size with rsync?

Tags:

rsync

I'm wondering if there is a way (a command) that i can use to find the size of rsync address, without starting syncing?

For example how i can find the size of rsync://mirrors.standaloneinstaller.com/vim/ ?

like image 991
m.qayyum Avatar asked Oct 23 '16 13:10

m.qayyum


1 Answers

If you combine the -n flag (dry run or simulate transfer, doesn't actually copy any files) and --stats you should be able to find out the total amount of files copied.

Example (simulating two files being copied locally, 445 bytes each):

$ rsync -avz -n --stats . ../test/
building file list ... done

Number of files: 14
Number of files transferred: 0
Total file size: 890 bytes
Total transferred file size: 0 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 299
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 315
Total bytes received: 20

sent 315 bytes  received 20 bytes  670.00 bytes/sec
total size is 890  speedup is 2.66

(Note the Total file size line.)

The official rsync docs state in the --stats section that

Total file size is the total sum of all file sizes in the transfer. This does not count any size for directories or special files, but does include the size of symlinks.

You can also consider the -h option that outputs numbers in a more human-readable format.

like image 56
Janek Avatar answered Dec 24 '22 18:12

Janek