For those of you who aren’t techies, here is a basic technique for bypassing the “middle man” (your own computer) when moving your website from one server to another. By harnessing the power of the Linux command line, you can really save some time in a most kickass way.
If you have a website with a lot of content, like large picture galleries or video files, moving to a new server presents some challenges. I’m going to ignore the obvious challenge of getting all the systems, like your blog system, your gallery program, etc, to work again. The most basic challenge I’ve found is simply moving those large files and directories. For example, if you have a directory with 400 megs of images in it, and you need to move the whole thing to a new server, but you have a normal DSL line at home with a horribly slow upload speed, it is simply not practical to download the whole directory to your computer then upload it to the new one. It will take all day.
The best way to move those files is server-to-server, no download-upload to and from your computer. Those servers, at most big hosting companies, will have a much faster rate of transfer than your home connection.
It also helps, at least for me, if the sites are being hosted on Linux systems.
You will need to know how to do simple navigation of Linux/Unix file systems. You’ll need to know how to make copies of files and whole directories from command line. It isn’t hard — but I’m not going to explain it here. Buy a basic Linux book.
First, you’ll need to be able to open an SSH window to both the new and the old servers. On Windows machines, you can do that with an application called PuTTY. PuTTY opens an SSH terminal window to your server(s). If you want to know what SSH is, read this. Basically it is a secure way to log into the servers. On a Mac you can use the Terminal application to do SSH.
Next, on the old server, identify all the files and directories you wish to move to the new server. If you want to move an entire directory, it is best to first make a copy of the entire directory and its contents. Then use the tar command to lump that entire copy of the original directory into a tar ball. You could do it without making a copy of the directory, but I’m always super safe when manipulating files. I always like a backup.
Once the tar ball is created, stay in that directory.
Now you will open a command line FTP session to the new server. If you don’t know what FTP is, read this. This could get weird. If you have already tranferred your domain name to the new server, you’ll have to make sure you still have access to the old stuff. Once you are logged into an FTP session, from the old server the new server, you can use regular Linux navigation to get to the directory where you’d like to put the tar ball. Do that.
Now, in your FTP session, a “pwd” command will show you where you are in the destination (new) server. But remember, you are still in the original directory on the old server that contains the tar ball. You can know use the FTP “put” command to simply move the tar ball over to the new server, cutting out the middle step of having it on your own computer.
Once you have moved all the files and directories you need to, quit the FTP session and log out of the SSH session to the old server. Open an SSH session to the new server, and use the the tar command to extract the contents of the tar ball. The old directories will magically appear on the new server.
Like I said, to do this you’ll need to have SSH access to your accounts on both servers, at the same time. So if you are running mysite. com, and you get a new account with a different company, and then change the DNS settings for your domain name, an SSH session to mysite.com will go to the new server — not the old one. You’d have to be able to hit the old server by it’s IP address, or some other way, to get to the old files.
This may seem like a lot of trouble, but it can seriously save you hours of upload time. I recently moved some directories what would have taken hours and hours to upload from my MacBook to the new server. Using this technique it only took a few minutes.
Again, here are the skills you’ll need some command of:
- Basic Linux file navigation and manipulation from the command line. It is pretty much the same as Unix, so Unix will generally work.
- Use of the “tar” function in Linux
- Use of the FTP function, from the command line, in Linux
- Ability to open an SSH session to both old and new servers, in order to do all of the above