Intro
If you manage one or more Joomla websites, eventually you’ll have to move them elsewhere. It’s pretty much fact. Performance requirements will change, you’ll find better pricing elsewhere, your dedicated server died, etc.
There are a few options most people have to choose from:
- FTP client and phpMyAdmin method (aka the long, boring method)
- SSH/Shell method (aka the cool, quick method)
- PHP system() method (aka middle of the road and kind of fun method)
- Joomla “clone” component (your mom could do it)
Move Joomla with an FTP Client and phpMyAdmin
- Download the entire Joomla website via FTP client (you’re using S-FTP to connect, right?)
- Use phpMyAdmin to export a SQL dump of your database
- Upload the entire Joomla website via FTP client
- Use phpMyAdmin on the new server to import the SQL dump from the old website
- Update configuration.php:
- Update the MySQL database credentials
- Update the tmp/logs path
- If you use FTP Layer, update the credentials
- Update .htaccess to match any changed server requirements
Easy and straightforward. Long, slow process, but any Jr. Network Admin could handle this for you if you don’t want to get your hands dirty.
Clone Joomla with SSH (shell) Access
- Login to your server via SSH
- Browse to your Joomla website root
- Run these commands:
[code lang=”bash”]tar -czf ../backup-example-com-20090619.tar.gz .mv ../backup-example-com-20090619.tar.gz ./
mysqldump -u yourUsername -p -h yourMySQLHostname yourDatabaseName > backup-example-com-20090619.sql[/code]
- Do you need to move this to a remote server or another location on the same server?
- Local Path
- Copy both backup files to the new website root
- Browse to the new Joomla website root
- Remote Path
- Login to remote server via SSH
- Browse to the new Joomla website root
- Use wget to download the archive and SQL dump to this server:
[code lang=”bash”]wget http://www.example.com/backup-example-com-20090619.tar.gz
wget http://www.example.com/backup-example-com-20090619.sql[/code]
- Local Path
- Run this command:
[code lang=”bash”]tar -xzf backup-example-com-20090619.tar.gz[/code] - Run this command (assuming you have made a new, blank database)
[code lang=”bash”]mysql -u yourNewUsername -p -h yourNewMySQLHost yourNewDatabase < backup-example-com-20090619.sql[/code] - Update configuration.php & .htaccess as shown in the first example
More complicated (obviously), but if you like doing things the hard fun way, then it’s a great way to go.
Using PHP’s system() or back-tick Commands to Copy Joomla Website
I wasn’t made aware of this method until after I started managing a whole slew of websites in a cloud hosting platform (Scale My Site). Cloud hosting (and many shared hosting platforms) do not provide access to SSH because it’s simply not feasible. Cloud hosting in particular due to your website running across hundreds of different server nodes. You can perform the same functions as the SSH procedure above using system execution commands in PHP.
- Create a new file called copy-me.php
- Write the following code into this file:
[code lang=”php”]echo `tar -czf ../backup-example-com-20090619.tar.gz . && mv ../backup-example-com-20090619.tar.gz ./`;
echo `mysqldump -u yourUsername -p -h yourMySQLHostname yourDatabaseName > backup-example-com-20090619.sql`;[/code] - Execute the PHP file by accessing it from a browser:
Browser> http://www.example.com/copy-me.php - Create a new file on the destination website called update-me.php
- Write the following code into this file:
[code lang=”php”]echo `wget http://www.example.com/backup-example-com-20090619.tar.gz`;
echo `wget http://www.example.com/backup-example-com-20090619.sql`;
echo `tar -xzf backup-example-com-20090619.tar.gz`;
echo `mysql -u yourNewUsername -p -h yourNewMySQLHost yourNewDatabase < backup-example-com-20090619.sql`;[/code] - Execute the PHP file by accessing it from your browser:
Browser> http://www.exampleDestination.com/update-me.php - Update the configuration.php and .htaccess files as needed
Cool, huh?
Use a Backup or Clone Component from Joomla Extension Directory
If you prefer not to do anything yourself, and want to keep it as simple as possible, then a backup component from the JED is the way to go:
http://extensions.joomla.org/extensions/access-&-security/backup
I have only used one of those components before, and I found that there were a few bugs needing to be worked out, and it ended up taking more time to do the backup, move, and clone that I needed to do than when I did so manually.
Foreward
There are shortcuts you can take here depending on your environment. For instance, you never need to create archives at all, as you can pipe the mysqldump output directly to another mysql command (with the new database’s credentials). However, I prefer to use archives and solid files especially when using PHP-based method, because you could end up accidentaly accessing the cloner file and wiping an existing MySQL database (if you aren’t careful). So, on top of all this, I’d recommend removing the update-me and copy-me files after using them.
thanks for this information . I want to change my hosting and you information help me to do it .