Part of the transfer or migration of a website many times involves a database. If you are on an “ix” server, SSH is a great way to backup your MySQL database.
Here’s how you do it:
Using SSH, navigate to your httpdocs or public folder on your server where the website resides.
Use the following command.
mysqldump –opt -u theusername -p thedatabasename > /path/to/backupname.sql
This creates a copy of your database.
Now, you can transfer that database backup to your new server.
If you ever have a need to migrate a website from one server to another, it can be a huge deal, especially when dealing with Magento, which has tens of thousands of files. Also, if your Magento store has many products, you have all those thousands of image files to move too. You could try FTP, but usually our servers hang during a large transfer. Even if you could do it by FTP, it would take hours at best to transfer a complete Magento site.
So here’s how to do a complete site migration using SSH. This can be used for any website you have root access to, not just a Magento site.
1. Login to server 1 via SSH and open the folder which you want to backup. You’ll probably need to login as root user.
Use this commands:
cd /home/somepath/to/yourwebsite/public_html
2. Make a compressed archive out of this folder using the command
Next:
tar -cvf sitepack.tar ./
3. Login to server 2 via SSH and use the command below to fetch the backup from server
wget yourdomain.com/sitepack.tar
4. Now uncompress the archive using the command
tar -xvf sitepack.tar
This is the easiest way we know of to move large websites with tons of files.
If you’re changing the directory structure of a website and you want to keep your pages indexed with Google and the other search engines, here’s an option for you, especially if you have a large number of pages to redirect.
Use the RedirectMatch command on Apache Servers.
In your .htaccess file, use the following code example:
RedirectMatch 301 /old-top-category/old-sub-category/.* http://www.your-domain.com/new-category.html
This will redirect all page or file calls from the previous directory to the new directory, on your same site. You could also use this to redirect to a different website.
If you’re trying to run an application or function and get an open_base_dir error message, open your vhost.conf file and put this code in there:
<Directory /var/www/vhosts/yourdomainname/httpdocs>
php_admin_value open_basedir none
</Directory>
<Directory /var/www/vhosts/yourdomainname/httpdocs>
php_admin_value open_basedir none
</Directory>
The vhost.conf file is usually here:/var/www/vhosts/yourdomainname.com/conf/
Then run the following command:
/usr/local/psa/admin/bin/websrvmng -a -v
and finally reload the web server:
/etc/init.d/httpd reload