Technical documentation on migrating WordPress sites between servers using rsync and mysqldump. Avoid plugin overhead and ensure data integrity with a command-line driven workflow.

Migrating a WordPress Site Without Plugins (rsync + mysqldump)

While migration plugins are popular, they often fail on large sites due to PHP execution timeouts or memory limits. For power users on Hovixa infrastructure, the most reliable method is a manual transfer using rsync for files and mysqldump for the database. This "out-of-band" approach is faster, more secure, and provides granular control over the migration process.

1. Exporting the Source Database

On the Source Server, create a compressed SQL dump. Using a dump ensures that all relational data and table structures remain intact.

# Export and compress the database
mysqldump -u db_user -p db_name | gzip > wp_migration.sql.gz
    

Tip: You can find your database credentials in the wp-config.php file.

2. Transferring Files via rsync

rsync is superior to FTP because it uses delta-transfer algorithms, only sending the differences between files. Run this command from the Destination Server to "pull" the data from the source.

# Syntax: rsync [options] [user]@[source_ip]:[source_path] [destination_path]
rsync -avzP -e ssh root@source_vps_ip:/var/www/html/ /var/www/html/
    
  • -a: Archive mode (preserves permissions and symlinks).
  • -v: Verbose (shows progress).
  • -z: Compresses data during transfer.
  • -P: Shows progress bar and allows resumed transfers.

3. Importing the Database

Once the wp_migration.sql.gz file has been transferred to the Destination Server (via the rsync command above), import it into your new, empty database.

# Uncompress and import
gunzip < wp_migration.sql.gz | mysql -u new_db_user -p new_db_name
    

4. Post-Migration Configuration

After the transfer, you must update the wp-config.php on the new server to match the local database credentials.

Task Manual Step
Update Config Edit DB_NAME, DB_USER, and DB_PASSWORD in wp-config.php.
Fix Permissions chown -R www-data:www-data /var/www/html/
Search & Replace If changing domains, use wp search-replace 'old.com' 'new.com' via WP-CLI.

5. Technical Implementation Details

  • SSH Keys: To automate or speed up rsync, ensure you have your SSH public key added to the source server's authorized_keys to avoid password prompts during the transfer.
  • Soft Links: rsync with the -a flag preserves symbolic links. This is critical if you use custom paths for your wp-content directory.
  • Large Databases: For databases larger than 2GB, consider using pv (Pipe Viewer) to monitor the progress of the import: pv wp_migration.sql | mysql -u user -p db.

Sysadmin Advice: Before updating your DNS to point to the new Hovixa VPS, edit your local **hosts file** to map the domain to the new IP. This allows you to test the migrated site in your browser to ensure the database and files are working perfectly without affecting public traffic.

Hasznosnak találta ezt a választ? 0 A felhasználók hasznosnak találták ezt (0 Szavazat)