Transferring your site to a new webhost doesn’t have to be a pain, today I’m going to provide you with an easy to follow guide for backing up your website and changing webhosts. This tutorial will guide you through using SSH, FTP, Pligg and phpMyAdmin methods for moving your data to a new server. These methods are not the only options for backing up your site, but they are some of the most commonly used and available methods. The tutorial seems long, but use the titles to skip sections that don’t apply to the method you choose for backing up your site. Before beginning let me quickly outline the two items that need to be saved when you want to backup your website. The first part is usually pretty obvious, the files on your server need to be saved to your computer and moved to another webhost. The second item is the data used to populate your site with stories, users, votes, settings and a variety of other information. This information is stored in a MySQL database on your web host and is kept separate from normal files.
Use SSH to Backup Your Files and MySQL Database
SSH is a secure method for connecting to your server. SSH is an interface where you can type in commands that will be processed by your server. SSH offers the absolute quickest way to perform a backup of your site, which is why it’s the first method described in this tutorial. Unfortunately SSH isn’t a graphics based method for making changes to your site so you will need to have a few lines of commands written down until you learn the basics. If you were using computers about a decade ago you might remember using the dull black screen and white text of DOS, which is a similar experience to using SSH.
To access your server using SSH from a PC I suggest downloading the program PuTTY
which is used in the screenshots for this article. Mac users are fortunate enough to already have a program installed called Terminal that can do the same thing as Putty. And if you are a Linux user you are probably already familiar with using a command line interface and I’m sure you already know what program you should be using.
The first step with Putty is to connect to the server. Looking at the image above, I’ve opened up putty.exe and have typed in the target domain into the Host Name field. I will then click Open and the window will turn into a command line interface seen below. It will then ask me for my username. After typing in your username (usually your FTP username) hit enter on the keyboard and it will then prompt you for a password. As you type your password you won’t see the text input advance. Don’t worry, your keyboard is still working so continue typing and hit enter when you finish. If you have a typo it will let you try the password again until you get it right.
Once you successfully log in it will show a line like the last one shown above (I’ve blurred out my domain in the example). To test what folder you’ve logged into on your server type in “ls” (ignore the quotes) and hit enter. It will then list all of the files in the current directory so you can get your bearings. You can then navigate around using the command “cd folder_name” to advance a folder or “cd ..” to go back a folder. For this tutorial I suggest you navigate to an area that is accessable via FTP, but not publicly viewable. Publicly viewable means that it’s not a folder that people on the web can access. Once you’ve found
mysqldump -u username -p database > pligg_backup.sql
It should take anywhere from 5 seconds to 5 minutes to run this command, depending on the size of your MySQL database. When it finishes you should see a new pligg_backup.sql file in the directory you issued the command from. If you want to refresh the directory listing from SSH type in “ls” and hit enter for it to list all of the files in the current directory. Now that you have the sql saved as a file you might want to consider compressing it to shrink the size of the file and make it easier to download. zipping the file will probably reduce the size of your .sql file to about half the size of it uncompressed. To compress the file just type the following command into your SSH program.
This next step will compress the folder your Pligg installation is located at. You will need to change the last part so that it points to the folder where Pligg is installed relative to what directory you are currently viewing from SSH. In the below example Pligg is installed in the public_html folder that is one level up from the directory I am currently browsing.
zip -r pligg_backup_sql.zip pliggbackup.sql
Once you have your files backed up to your computer and you verify that they are all valid you can upload the pligg_backup_files.zip file to your new web host where you want to install Pligg at and then open up SSH to the directory where you uploaded the file and run this command to unzip the file.
zip -r pligg_backup_files.zip public_html/
Use FTP to Backup Your Files
FTP is one of the first technologies that web admins pick up because it’s an easy to use method for adding and removing files from a web host. FTP is limited though and does not offer features such as zipping and unzipping files on your server, which is a critical feature if you want backing up files to be a speedy process. Programs like WinSCP are able to offer some of the benefits of a GUI FTP interface along with archiving (and sometimes un-archiving) abilities, so for the sake of speed I suggest using WinSCP to zip files before downloading. Unfortunately a lot of servers won’t allow WinSCP to extract files using this method, so uploading files to the new web host will be a much slower task than downloading them.
FTP isn’t a solution for backing up your MySQL data so you will need to couple FTP with a tool like phpMyAdmin to make a backup of your MySQL data.
Use phpMyAdmin to Backup Your MySQL Database
If you haven’t used phpMyAdmin in the past, this tutorial shouldn’t be a problem. phpMyAdmin offers a great interface for modifying, importing and exporting your MySQL database and it’s a great tool that web admins should learn sooner than later. Most web hosts offer it as part of their standard hosting features because it’s the most common graphical user interface method to modify your database. To access your phpMyAdmin panel you will need to either enter the server address where your MySQL is stored (ex. mysql.domain.com) or find a link to phpMyAdmin from your web host admin page. Cpanel has a link at the bottom of the MySQL page if memory serves. You will log in to phpMyAdmin using the MySQL username and password that you set up when creating a MySQL database. Once logged in you might need to select the database from a drop down menu or list of databases on the left side of the screen. Once you have selected the database name that you want to backup click on the “Export” tab on the top of the right side of the screen. Then click on the “Select All” link to make sure that all of the tables in the database are going to be saved.
The last step is to go to the bottom of that page and click on the “zipped” option to compress the sql and click the Go button to download the .zip file to your computer.
That’s it for backing up your MySQL database for Pligg. One final note though for those who are attempting to use phpMyAdmin to backup large databases. I’ve discovered that when your database becomes rather large phpMyAdmin won’t be able to export successfully, which is why I recommend using SSH for backing up sql.
Use Pligg CMS to Backup Your Files and MySQL Database
Last but not least is a built in tool offered by Pligg Content Management System that makes backing up your site as simple as 3 clicks. Navigate to your admin panel and click on the Backup link located within one of the widget areas (no longer a navbar item).
Click on the 3 links to backup your files, avatars and MySQL database and as you click on each one it should generate a new file at the bottom of the page. Download the 3 generated files and save them to your desktop and be sure to check that the zip files contain the correct information. When you confirm that the downloads are complete and correct click on the Remove link from the backup page to delete the backup files from your server. I suggest using the Pligg backup method as a secondary option just so that you don’t keep your eggs all in one basket.