DigitalOcean does not block anyone from migrating their websites / applications around - WordPress included.
There are a few ways to do so - this is one.
- ssh into your droplet
cd /PATH/TO/WEBROOT
- issue the following command(s):
DBNAME=$(grep DB_NAME "wp-config.php" | cut -d "'" -f 4); \
DBUSER=$(grep DB_USER "wp-config.php" | cut -d "'" -f 4); \
DBPASS=$(grep DB_PASSWORD "wp-config.php" | cut -d "'" -f 4); \
mysqldump -u${DBUSER} -p${DBPASS} ${DBNAME} > ${DBNAME}.sql
This will drop a copy of your database into the same directory as your wordpress installation. Please note this works only for a standard WordPress installation - This can also be done quite easily with phpMyAdmin if it is available.
- package up everything using whatever archive tool you choose - I prefer zip -
zip -r ../html.zip /PATH/TO/WEBROOT
This will place a *.zip archive one directory up.
move the archive to the new server scp ../html.zip USERNAME@IP_OR_HOSTNAME:/PATH/TO/WEBROOT
Leave your droplet
Within the new host create your new database using whichever tool is available or proffered
ssh into your new host and cd /PATH/TO/WEBROOT
unzip html.zip -d ./
copy the old wp-config cp wp-config.php wp-tempfile
- we are only going to use this temporarily
edit the wp-config.php file updating the database connection details with that of your new host
upload the database
OLDDBNAME=$(grep DB_NAME "wp-tempfile" | cut -d "'" -f 4); \
DBNAME=$(grep DB_NAME "wp-config.php" | cut -d "'" -f 4); \
DBUSER=$(grep DB_USER "wp-config.php" | cut -d "'" -f 4); \
DBPASS=$(grep DB_PASSWORD "wp-config.php" | cut -d "'" -f 4); \
mysql -u${DBUSER} -p${DBPASS} ${DBNAME} < ${OLDDBNAME}.sql
- remove zip archive and wp-tempfile
rm -v wp-tempfile html.zip
Please note that this may need to be adjusted to suite your server setup for the source and destination server and wordpress installation - i.e. you may need to install and configure NGINX/APACHE, MySQL/MariaDB etc…
Another solution is to use something like this
https://en-ca.wordpress.org/plugins/wp-migrate-db/