Image

(Last change: 24.04.2024)

To transfer the site through the command line, you need ssh access to the current and new server. Transferring sites via the command line requires Linux skills, and for this part of the clients it can be a more familiar way.

Creating a site archive

First, we need to go to the server and dump the database, you can see the details for connection in the configuration file of your cms, as a rule this file is called config.php. It contains the database name, username and password for the connection. We execute the command to take the database to a file, it is also worth making sure that we are at the root of the site so that the file that we will create is there.

Database Export:

mysqldump --add-drop-table -u -p dbname > dbname.sql


Variables , , dbname - must be replaced with your own, which are specified in the configuration file of your cms. After the command is executed, the command line will do a line feed and use will again be available.


Check the availability and size of the file, after which you should proceed to archiving the files including the sql database file that we created.


Archiving:

tar -czf workspace.tar.gz *


Where workspace.tar.gz is the name of the archive. The name of the archive can be changed to the name of the site and execute the command in the root folder. In this case, all folders and files are archived, including subfolders. Now you can download the archive, it is ready for deployment on a new hosting server.


Deploy archive with site

Copy the archive through the ftp server and use the ssh command to unzip it to the root folder (for the first site, it is called httpdocs by default)


Unpacking:

tar -xzvf workspace.tar.gz

Make sure that all files are located in the root folder including the database file that will need to be imported. Create a new database in the hosting control panel, a user with a password, and specify this data in the import command.

Import Database:

mysql -u -p dbname < dbname.sql


Wait until the command line completes the line and becomes available for use again.

Now you need to specify new data in the configuration file of your cms, in our example we used config.php - specify in it the new database name, username and password that we used when importing the database. Try to open the site through a browser, if errors occur or appear, you can find and eliminate the cause by viewing the log in the hosting control panel. You can also contact technical support by opening a request in your account.

Note: command line (ssh) is available only in Business and Business + tariffs.

Due to the rare use of the command line for security reasons for Business and Business + tariffs, the command line in chroot mode is enabled by default, in order to remove this restriction, contact technical support.