Migrating a Simple Drupal-Site via SSH
Note that this is a personal workflow of mine and not a tutorial. Commands may vary according to your setup.
Prepare the following
From old server go to Drupal's folder /sites/default/
then open the settings.php
file. Scroll down to database settings and copy the old_databse_name
, old_database_user
, and old_database_password
.
In the new server, create a new database, take note of new_database_name
, new_database_user
, new_database_password
.
From the Old Server
Go inside backups folder inside the home directory, mkdir backups
if none.
Create database backup: mysqldump -u old_database_user old_database_name -p > database_backup_name.sql
and enter the old_database password
when asked.
Create file backup: tar -czvf file_backup_name.tar.gz /directory/path/of/Drupal/site/
Copy database_backup_name.sql
and file_backup_name.tar.gz
to a public folder, say to /directory/path/of/Drupal/site/
then cd
to that folder. mv database_backup_name.sql database_backup_name.xyz
In the New Server
Go inside backups folder inside the home directory, mkdir backups
if none.
FTP the files from old server.wget https://yourdrupalsite.tld/file_backup_name.tar.gz
wget https://yourdrupalsite.tld/database_backup_name.xyz
mv database_backup_name.xyz database_backup_name.sql
Import database_backup_name.sql
to the new servermysql -u new_database_user -p -D new_database_name < database_backup_name.sql
Enter the new_database_password
when asked.
Uncompress the files to backups
foldertar -xf file_backup_name.tar.gz
cd file_backup_name/Drupal...folder/sites/default
Change permission in order to move and edit the filechmod 777 settings.php
cd file_backup_name/Drupal...folder/
Move the files to public Drupal directorymv * /path/to/new/Drupal/site/
mv .htaccess /path/to/new/Drupal/site/
Edit the settingscd /path/to/new/Drupal/site/
nano settings.php
Go to the database array and enter the appropriate new_database_user
, new_database_name
and new_database_password
.
Revert permission to non-writable after saving the filechmod 444 settings.php
Done.
Comments