Score:1

sftp the directories has different sizes after transfer?

ua flag

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?

digijay avatar
mx flag
What was the command you move the files with?
Mr Sparrow avatar
ua flag
sftp) get -rp foldername
Score:2
ca flag

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
Score:0
jo flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.