How to transfer a site to another hosting or tariff yourself remotely, without downloading to a computer
The site may need to be transferred at any time to another tariff or hosting. For this, technical support is often involved, but it may refuse or respond for a long time, not to mention the transfer speed itself. Therefore, you need to perform migration of the site yourself.
To do this, first you need to archive the site files, a ZIP archive will do. You can use hosting tools, or you can use SSH. Creating such an archive is easy, you can use the SSH command:
zip -r archive-name.zip /folder-path
After that, you can download the archive to your PC, but in order not to waste traffic and not wait a long time for downloading, and then uploading to a new hosting, you can use remote transfer from one server to another. There is an SSH command for this:
wget https://example.com/archive.zip
In order to use this command, you need to SSH into the destination host and run it. But first you need to move the resulting archive on the source hosting to the site folder so that you can download it from the URL. For security purposes, it is better to name the archive with a random set of characters so that no one can download your site by accident. As soon as the archive is downloaded, the archive must be immediately removed from the site directory. After that, on the final hosting, you need to unzip:
unzip archive-name.zip
It remains to transfer the database remotely, for this there is the mysqldump utility, the SSH command with archiving:
mysqldump -u username -puserpassword dbname | gzip > path-to-target-file.sql.gz
The password is not indented from the p parameter. After that, the resulting archive is moved to the site folder and downloaded in the same way as site files using the wget utility. It is important to use random names and do not forget to delete the archive in the root of the site after the operation is completed.
Next, the resulting dump is loaded into a new database on the final hosting using the SSH command:
gunzip < path-to-dump-file.sql.gz | mysqldump -u username -puserpassword dbname
It remains only to check the integrity of the files and delete the old hosting service, and update the database connection settings on the new one if necessary. You may also need to transfer the SSL certificate and perform other settings with adding, setting up a domain, etc. It won't take long, you can skip the update of DNS records for the domain and use VPN, for example, in the Opera browser - to quickly check the site's performance on a new hosting.
Latest articles
- 03.04.24IT / Уроки PHP Уроки простыми словами. Урок 3. Все операторы PHP с примерами, с выводом работы кода на экран.
- 02.04.24IT / Уроки PHP Уроки простыми словами. Урок 2. Типы данных в PHP с примерами.
- 02.04.24IT / Уроки PHP Уроки простыми словами. Урок 1. Коротко о языке веб-программирования PHP. Основы синтаксиса.
- 09.11.23IT / Database Errors when migrating from MySQL 5.6 to 5.7 and how to fix them - database dump import failed with an error or INSERT does not work. Disabling STRICT_TRANS_TABLES strict mode or using IGNORE
- 08.07.22IT / Misc Convert office files DOC, DOCX, DOCM, RTF to DOCX, DOCM, DOC, RTF, PDF, HTML, XML, TXT formats without loss and markup changes