I am in the midst of moving my sites from one host to another and need to tar the directories to make them easier to move, then untar them once I have moved them. It's much quicker this way than downloading all of the files and uploading them to the new host.
For the code below, you'll want to type anything that is after the $.
SSH to your old server
Start by opening terminal.
ashedryden:~ ashedryden$ ssh username@site
Hit enter and you'll be prompted for your password.
username@site's password:
Enter your password and hit enter again.
This will drop you into the top directory. If you type ls it will give you a list of all of the directories or files where you currently are.
Maildir ashedryden.com ashleydryden.com logs tmp comingoutpoly.com dev.ashedryden.com
Tar a specified directory
Now I can tar the directory in preparation to move it.
ashe:~$ tar -pczf ashedrydencom.tar.gz ashedryden.com/
It may take a few seconds depending on the size of the directory. Now you can ls again and see that your file was created.
Maildir ashedryden.com ashedrydencom.tar.gz ashleydryden.com logs tmp comingoutpoly.com dev.ashedryden.com
Move the tar'd file to a different location
Next we want to move the file to the new server.
scp ashedrydencom.tar.gz username@othersite:/directoryonnewserver
SSH to your new server and untar the newly-moved file
Finally, we want to login to the new location to untar the file.
First, disconnect from the old server.
ashe:~$ exit
Next, login to the new server.
ashedryden:~ ashedryden$ ssh username@site
Again, it'll ask you for your password.
username@site's password:
Type your password and hit enter. You can ls here, too, to see what directories and files are at your location.
ashedrydencom.tar.gz
As you can see, right now the only thing I have here is the file I moved. Now we can untar it.
ashe:~$ tar xvfz ashedrydencom.tar.gz
Once this is done, you can ls again to see the end result:
ashedryden.com ashedrydencom.tar.gz
You don't need the tar'd file anymore, so you can delete it if you like.
ashe:~$ rm ashedrydencom.tar.gz
And you're done! It looks like a lot of steps, but it's really very easy to do and it'll save you a ton of time.

RSS Feed