Skip to content

If you need your own WordPress server with HTTPS and Backups.

Notifications You must be signed in to change notification settings

anklav24/wordpress-docker

Repository files navigation

WordPress, MySQL, Redis, phpMyAdmin, Traefik (TLS, HTTPS), Docker, Uploading to Google Drive

Overview

If you need your own WordPress server with HTTPS and Backups.

Requirements

  • Oracle VPS Free Tier ARM (VM.Standard.A1.Flex) I did on 4 CPU Ampere 24 RAM.
  • Ubuntu 20.04 ARM

Version

  • docker-compose version 2.4
  • wordpress:php8.0
  • redis 6.0.15-alpine
  • Zabbix agent 5.0.16
  • Postgres 12
  • Traefik 2.5.3
  • Portainer 2.9.3-alpine
  • phpmyadmin 5.1.1
  • pgadmin 4.6.2
  • mysql-server:8.0 (Oracle)

Tested

  • 2021-12-21

Installation

Clone the repository

cd ~ &&
git clone https://github.com/anklav24/wordpress-docker &&
cd wordpress-docker

Select a develop branch (Optional)

git checkout develop

Rename deploy_configs_example, .env.example

  • deploy_configs_example -> deploy_configs
  • .env.example -> .env

Check deploy_configs, *-docker-compose.yaml, .env

Replace domains, envs, emails, logins, passwords and tls.certresolver on yours! Don't use examples in production!

Install Docker, Docker-compose and other stuff.

chmod +x install.sh && ./install.sh

Install gdrive as root user

# Example
gdrive list --absolute --query "mimeType = 'application/vnd.google-apps.folder' and name contains 'backup'" --max 1000
  • Change in 4soulsband_wordpress_backup.sh gdrive_folder_id variable to your Id

Setup Yandex Drive Aouth token

  • In .env add your YANDEX_TOKEN
  • Go to web yandex disk and create folder /backups/sites_backup/ or change the path in the backup scripts

Setup logrotate for traefik

  • Setup logrotate check config in deploy_configs/logrotate.d/traefik
  • Or turn off logs

After install go to check your wordpress domain

Run compose files

cd ~/wordpress-docker
docker-compose -f 1-docker-compose.yaml up -d; 
docker-compose -f 2-docker-compose.yaml up -d

UI Links

References

Troubleshooting:

If a WordPress site has the "gateway timeout" error, you need to set default network for traefik:

- traefik.docker.network=traefik_proxy_net

Useful commands

Redis

docker exec -ti redis redis-cli -p 6380 monitor

docker exec -ti redis redis-cli -p 6380
127.0.0.1:6379> KEYS *

Systemd service

Set up backup automation:

sudo cp systemd_services/* /etc/systemd/system/  # Copy services and timers files.
sudo systemctl start 4soulsband_wordpress_montly_backup.service  # Check the service works properly (Example)
sudo systemctl enable 4soulsband_wordpress_montly_backup.timer  # Enable a timer (Example)
sudo systemctl daemon-reload  # Reload systemd after service changing.
clear; sudo systemctl status *4sou*timer  # Check backup timers
sudo systemctl list-timers  # Check all timers

sudo systemctl start 4soulsband_wordpress_daily_backup.service  # Start the backup manually.
sudo systemctl start 4soulsband_wordpress_weekly_backup.service  # Start the backup manually.
sudo systemctl start 4soulsband_wordpress_yearly_backup.service  # Start the backup manually. With Google Drive Sync

journalctl -u 4soulsband_wordpress_daily_backup.timer  # Check logs
journalctl -u 4soulsband_wordpress_daily_backup.service  # Check logs

Backup and restore

Backup

# Example
./4soulsband_wordpress_backup.sh daily 7 YOUR_DATABASE_NAME YOUR_DATABASE_USER YOUR_DATABASE_PASSWORD true
# Need args: task_name (daily, monthly, yearly), days_to_keep (7, 186, 1825), mysql_db_name, mysql_user, mysql_password, [debug (true)]

Restore

# Before you need change timestamp and backup_dir_name variables in the file 
./4soulsband_wordpress_restore.sh daily YOUR_DATABASE_NAME YOUR_DATABASE_USER YOUR_DATABASE_PASSWORD true
# Need args: task_name (daily, monthly, yearly), mysql_db_name, mysql_user, mysql_password, [debug (true)]

Releases

No releases published

Packages

No packages published

Languages