Continued from page 1
"dump.tar" is name of file we want to save into, and "*" means we want to put everything into this TAR archive -- files, folders, everything.
You may get some sort of warning about not adding dump.tar to archive, that's no big deal because we don't want this file to add itself.
Your files are backed up. At this point it's time to move things over to next host. There's a way we can do this without you having to download whole thing, and re-upload it.
STEP 4: ARRANGE YOUR FILE FOR PICKUP
Remember how I said when you were in "wwwroot" or "public_html" not to browse into folder containing a domain name? Well now it's time to move that dump over into one of them so it can be picked up.
If one of your folders is, say, yourdomain.com, type:
mv dump.tar yourdomain.com
This moves "dump.tar" into folder "yourdomain.com".
STEP 5: MOVE THE NEW FILE OVER
Login to your new host. Browse to its "wwwroot" or "public_html" folder.
Most hosts include a program called "wget" which works sort of like a browser in that you give it a URL to pick-up that it loads. Only this browser also saves file you want to load.
If your old host was at yourdomain.com, you'd just type:
wget http://www.yourdomain.com/dump.tar
This will load that URL and save it as "dump.tar". You'll probably see some sort of progress indicator as it goes.
STEP 6: DECOMPRESSING THE FILE
Once you have file, you use that same TAR program to decompress it. Type:
tar -xvf test.tar
The "v" and "f" are still there, but instead of "c" (create) we use "x" (extract). This will unpack each file and let us know which one it's working on.
STEP 7: RESTORING THE MYSQL DATABASE
Before you can put mySQL dump back into database, you have to go into this new web host's control panel and create blank databases with same names as you had before.
You also have to create a mySQL user and make sure that user has access to all those databases you've created.
Once that's done find dump.sql that was unpacked with all of other files.
Instead of using program "mysqldump" to dump files, we use program "mysql" which let's us put commands into database. That's basically what a dump is, a file full of commands that, when run, will recreate old database exactly.
This time we don't type in database name right away. To get into mySQL from command prompt, type:
mysql -umyuser -pmypassword
Where "myuser" and "mypassword" are your mySQL username and password. Once you're in you'll get kind of a weird looking prompt. All you have to do at this point is type:
source dump.sql
This says, open up file dump.sql, read through it and do whatever it says to do in that file. You will see a bunch of lines telling you a command has been entered (0 Rows Affected, 1 Rows Affected, something like that).
If everything goes smoothly, type "quit" and you will be back in shell.
You've just moved one site (or a bunch of sites) over from one host to another in about 5 minutes.
Article by Robert Plank
Want to pick up more useful PHP and programming skills, even if you aren't "the programming type"? Subscribe here -- http://jumpx.com/newsletter