(I'M NOT ENGLISH!)
Hello everybody,
Yesterday I decided to move my web server from a German datacenter to US. Then I needed to copy the whole system and then make the changes to the configurations (because of IP change).
First of all, I installed a fresh and simple FreeBSD on the destination system to be able to use the basic commands and tools such as SSH and SCP.
At first, I tried the scp command to copy files as below:
(I couldn't use the dd command, because the hard disk space was changed.)
Using the above command, I faced a weird problem. The speed of copying a file was very good (around 5-6 MB/s). But there was more than one second delay while switching between files. As you know, the operating system environment consists of so many small files and the 1 second delay between each file may need a couple of days to copy 3 GB of small files.
So I researched a little and remembered the Named Pipe thing exists in modern *NIX-like OSes. So I ran the following commands on the source computer:
The first command creates a new Named Pipe. The second command tries to create a compressed archive from the root directory to the created Named Pipe. But since there is no program at the other end of the pipe, it blocks temporarily.
Then I ran these commands on the destination server:
The first command creates another Named Pipe but in the destination server. The tar command tries to read the pipe and extract it, but because there is nothing at the other end of pipe, it blocks. The ssh command actually connects the end of two pipes to each other by sending the end of the source pipe to the start of the destination pipe. At this time, the source pipe has an end and the tar command on the source server starts archiving and compressing files. And the destination pipe also has a sender at its other end and the tar command starts extracting the archive. In this case the archive created on the fly and there is no need to store the whole archive as a separate file (which needs space that I didn't have!) and it takes less than half the time. Actually the archiving, moving and extracting operations are executed simultaneously and in parallel.
And the whole copying was completed in less than 30 minutes! I think I created a wormhole (http://en.wikipedia.org/wiki/Wormhole)
[ Edited - see port #8 and #9 below - Mod. ]
Hello everybody,
Yesterday I decided to move my web server from a German datacenter to US. Then I needed to copy the whole system and then make the changes to the configurations (because of IP change).
First of all, I installed a fresh and simple FreeBSD on the destination system to be able to use the basic commands and tools such as SSH and SCP.
At first, I tried the scp command to copy files as below:
(I couldn't use the dd command, because the hard disk space was changed.)
# scp -C -p -r root@<source_ip>:/ /
Using the above command, I faced a weird problem. The speed of copying a file was very good (around 5-6 MB/s). But there was more than one second delay while switching between files. As you know, the operating system environment consists of so many small files and the 1 second delay between each file may need a couple of days to copy 3 GB of small files.
So I researched a little and remembered the Named Pipe thing exists in modern *NIX-like OSes. So I ran the following commands on the source computer:
# mkfifo /tmp/portal
# tar czpf /tmp/portal /
The first command creates a new Named Pipe. The second command tries to create a compressed archive from the root directory to the created Named Pipe. But since there is no program at the other end of the pipe, it blocks temporarily.
Then I ran these commands on the destination server:
# mkfifo /tmp/portal
# cd /
# tar xzf /tmp/portal &
# bg
# ssh root@<source_ip> 'cat /tmp/portal' > /tmp/portal
The first command creates another Named Pipe but in the destination server. The tar command tries to read the pipe and extract it, but because there is nothing at the other end of pipe, it blocks. The ssh command actually connects the end of two pipes to each other by sending the end of the source pipe to the start of the destination pipe. At this time, the source pipe has an end and the tar command on the source server starts archiving and compressing files. And the destination pipe also has a sender at its other end and the tar command starts extracting the archive. In this case the archive created on the fly and there is no need to store the whole archive as a separate file (which needs space that I didn't have!) and it takes less than half the time. Actually the archiving, moving and extracting operations are executed simultaneously and in parallel.
And the whole copying was completed in less than 30 minutes! I think I created a wormhole (http://en.wikipedia.org/wiki/Wormhole)

[ Edited - see port #8 and #9 below - Mod. ]