1

i am moving folders from server into another debian -> centos using sftp .

the folders size is different after the transfer is done . for example :

remote server :

sftp 00.00.00
sftp get folderName ( size 87mb)

on local server :

du -sh * 
folderName ( size 83mb )

is it possible i am not transferring the hidden files and folders?

Mr Sparrow
  • 111
  • 1

2 Answers2

2

I'm not familiar with sftp, but the cause is probably a unit difference: du shows size in MiB while sftp might show Mb. To convert from one to the other, multiply the size given by sftp by 1000*1000/(1024*1024) (87 -> ~83).

Wikipedia page on the subject : https://en.wikipedia.org/wiki/Byte#Multiple-byte_units

Note that if you transfer very small files, you might some day notice that du shows a greater size than expected. This is because du shows the reserved size of the files on disk, which is greater than the actual 'usefull' size that is calculated by sftp.

Edit: to test this behavior, you can create a file with a controlled size and tranfer it. To create a 32 MiB (~33MB) file:

# 1048576 is 1 MiB (1024*1024)
dd if=/dev/zero bs=1048576 count=32 of=testfile
cg_foreau
  • 93
  • 6
0

Folders can grow in size but not shrink (at least on EXT4). The most probable reason for this result is that at one point in time the source directory had many more file in it that were subsequently removed.

Whereas at the destination the number of files inside the directory is (and only has ever been) what you just copied -- which is less than what the max has been in the source directory.

One way to 'test' this idea would be to copy all the files from the same source to a different destination on the SAME server using the SAME filesystem mounted.

You should find that the new copy has a directory of the same size as the one on the SFTP destination.

Matthew Ife
  • 22,927
  • 2
  • 54
  • 71