Report this

What is the reason for this report?

What's the best way to move database and www files from an out of date LAMP droplet to a new LAMP droplet?

Posted on August 26, 2025
WTPX

By WTPX

My current LAMP droplet is having issues updating mysql and apache so I am planning on moving the DB and web files to a new droplet. What is the best way to move all of these things but not move any of the out dated server install?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya,

Here’s the best approach to migrate just your data and web files to a new LAMP droplet:

Database Migration

Export from old server:

# Create a dump of all databases (excluding system databases)
mysqldump --all-databases --single-transaction --routines --triggers --user=root -p > all_databases.sql

# Or export specific databases:
mysqldump -u root -p database_name > database_name.sql

Import to new server:

# Transfer the file to new server, then:
mysql -u root -p < all_databases.sql

Web Files Migration

Copy web files (excluding system files):

# From old server, tar your web content
cd /var/www
tar -czf web_files.tar.gz html/

# Transfer to new server (use scp, rsync, or similar)
scp web_files.tar.gz user@new-server-ip:/var/www/

On new server:

cd /var/www
tar -xzf web_files.tar.gz
chown -R www-data:www-data html/
chmod -R 755 html/

Configuration Files to Copy

Only copy application-specific configs:

  • Apache virtual hosts: /etc/apache2/sites-available/
  • PHP application configs (like wp-config.php, .env files)
  • SSL certificates if you have custom ones

Don’t copy these system files:

  • Main Apache config (apache2.conf)
  • PHP main config (php.ini)
  • MySQL config (my.cnf)

Step-by-Step Process

  1. Set up the new LAMP stack with current versions
  2. Test the new environment with a simple PHP file
  3. Export databases from old server
  4. Copy web files (just the content directories)
  5. Import databases to new server
  6. Copy only necessary config files (virtual hosts, app configs)
  7. Update file permissions and ownership
  8. Test everything thoroughly before switching DNS
  9. Update DNS to point to new server

This approach gives you a clean, updated server environment while preserving all your data and applications.

You might have any custom services you need to move as well

Since we don’t know your setup, we can’t guide you here but bear in mind that if you have some services that go alongside your application like NodeJS or Gunicorn or w/e, you will need to move them over as well.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.