Copy Files To Remote

Assuming os x on the local machine and Ubuntu Linux remote.

First I will create tar archive with tar

tar -cvzf lessons.tar.gz lessons

Flags: c - create v - verbose z - gzip f - archive filename

Then split files in smaller pieces if something goes wrong with a connection.

split -b 250mb lessons.tar.gz lessons_part_

This will create files

lessons_part_aa
lessons_part_ab
lessons_part_ac
lessons_part_ad
...

When you want to send files from local computer to remote you can use scp tool

scp ./lessons_part_a* root@remote-host.net:/root/tmp/

After broken connection you can continue with command

scp ./lessons_part_a{g,h,i} root@remote-host.net:/root/tmp/

I probably shouldn't use root user.

I wanted to check if files are ok. Type md5 * to get md5 hashes on my mac, and md5sum * on the remote Ubuntu. If the has numbers are same then everything is good.

Now ssh to the remote.

ssh root@remote-host.net
cd /root/tmp/

and join the files

cat lessons_part_a* > lessons.tar.gz

and extract tar archive

tar -xzvf lessons.tar.gz

There are smarter and easier ways to accomplish same thing, but this was fun and educational. I learned few new commands.

Author

I plan to write more articles about common laravel components. If you are interested let’s stay in touch.
comments powered by Disqus