
In this tutorial we are going to go through moving a Ubuntu 20.04 Word-Press installation to a different VPS with some crafty bash scripting.
#!/bin/bash
clear
SITE=yoursite #File Directory of wordpress on server
APACHE=yoursite #Sites-available apache config file
LETSCA=yourdomain.ca #Let’s config for .ca
LETSCOM=yourdomain.com #Let’s config for .com
DB=your_db_name #SQL database name
echo ———————————————————
echo “ls -lah /var/www/”
ls -lah /var/www/
echo $SITE
echo ———————————————————
echo “ls -lah /etc/apache2/sites-available/”
ls -lah /etc/apache2/sites-available/
echo $APACHE
echo ———————————————————
echo “ls -lah /etc/apache2/sites-enabled/”
ls -lah /etc/apache2/sites-enabled/
echo $APACHE
echo ———————————————————
echo “ls -lah/etc/letsencrypt/archive/”
ls -lah /etc/letsencrypt/archive/
echo $LETSCA
echo $LETSCOM
echo ———————————————————
echo “DB name”
cat /var/www/yoursite/wp-config.php | grep DB_NAME
echo $DB
echo ———————————————————
read -p “Press enter to continue or CTRL+C to exit”
tar -cvf $SITE.tar /var/www/$SITE/
tar -rvf $SITE.tar /etc/apache2/sites-available/$APACHE-le-ssl.conf
tar -rvf $SITE.tar /etc/apache2/sites-available/$APACHE.conf
tar -rvf $SITE.tar /etc/apache2/sites-enabled/$APACHE-le-ssl.conf
tar -rvf $SITE.tar /etc/apache2/sites-enabled/$APACHE.conf
tar -rvf $SITE.tar /etc/letsencrypt/archive/$LETSCA
tar -rvf $SITE.tar /etc/letsencrypt/archive/$LETSCOM
tar -rvf $SITE.tar /etc/letsencrypt/live/$LETSCA
tar -rvf $SITE.tar /etc/letsencrypt/live/$LETSCOM
mysqldump -u root -p $DB > $SITE.sql
tar -rvf $SITE.tar /tmp/move/$SITE.sql
read -p “Press enter to continue or CTRL+C to exit” #read -p makes a prompt message in terminal for user input required
echo “compress file”
gzip $SITE.tar #Compressing file directory of wordpress
read -p “Press enter to continue or CTRL+C to exit”
echo “SCP file to other server”
scp $SITE.tar.gz root@target_ip:/tmp/move/
STAY IN THE LOOP
Subscribe to our free newsletter.
I-Innovate: TESLA Construction Management Application