Ubuntu – Some files are not transferred by using rsync between 2 servers

copyrsyncUbuntu

I used rsync with -av parameter to migrate a website from one server to another.
there was no error displayed but the size of the folders are not the same and the website does not work correctly. so something is missing.
Is there a parameter who copies really everything ? i have sudo accounts on both sides ofc.

I check folder size with du -s dir , the sizes are the following :

old server : 2554620

new server : 2547676

it's in bytes.
How do I manage to have the exact copy?

Wordcount output:

old server :  2663    3105  175534
new server :  2665    3107  175594

Best Answer

Its possible some of the files arent satisfying rsync's default size & date. Get rsync to transfer based on check sums instead. It will be slower, but if the file has changed in anyway, it will be transfered.

rsync -cav <source> <destination>

If you want to check that it will transfer the files you want, add -n to the end of the command to get a dry run. You can then check the list for missing files, or even easier, if you have a specific filename that you know wasn't being transferred before, just grep for it!

rsync -cav <source> <destination> -n | grep some-missing-filename

UPDATE: If you're not sure if the contents of the folders are the same, then you can check easily with the following:

on each server:

cd /to/root/of/your/website
find . | md5sum

And then compare the md5 check sum which is output, if the number is the same, then you have the same files (e.g. file1 on server1 and on server2) although this doesn't account for the file contents being different

If you want to see what files exist in one, but not in another, then you can of course output directory listings to files:

cd /to/root/of/your/website
find . > server1.txt

... on both servers, and then

diff server1.txt server2.txt

Just one final thought:

scp -r user@server1:/path/to/website /path/to/website
Related Topic