A collection of bash scripts for creating, and maintaining a wordpress website using docker. Tested in Ubuntu 22.04.
There are a few basic prerequisites which can be installed by:
git clone https://github.com/abarmpou/WordpressDockerManagement.git
WordpressDockerManagement/lightsail_setup.sh
In the terminal type: ./create_site.sh somesite
This will create a docker wordpress container somsite_wp and a database container somesite_db and will make the site accessible at http://localhost:8101/.
If you want to create the site in a specific path type: ./create_site.sh -u https://www.example.com/some/site/ somesite
This will create a docker wordpress container somsite_wp and a database container somesite_db and will make the site accessible at http://localhost:8101/some/site/.
To copy the database from an existing wordpress site you need to do: mysqldump --no-tablespaces --single-transaction -u user -p DBNAME > backup.sql
and zip the website files by going into the directory cd /var/www/html zip -r /home/user/backup.zip .
In the terminal type: ./change_url.sh -u https://www.example.com/some/site/ somesite
This will change the wordpress url entries in somesite_db database to https://www.example.com/some/site/
In the terminal type: ./backup_site.sh somesite
This will save the website files in a file somesite_datestamp.zip and the database in a file somesite_datestamp.sql.
In the terminal type: ./remove_site.sh somesite
This will stop and remove the containers somesite_wp and somesite_db. If you also want to remove the files from your local drive type: rm -r somesite.
If you have previously used backup_site.sh to create a backup of a wordpress website, you can restore it by the following:
./create_site.sh somesite
./restore_site.sh somesite somesite_datestamp