tips_and_howtos:wordpress_upgrade

Wordpress Upgrade done simple

As simple as it gets. Upgrade your WordPress from your command line with common Linux server skills.

This is for Mariadb in localhost with default settings and will prompt for admin password.

mysqldump --add-drop-table -u <adminuser> -p wordpress > wordpress-yyyymmdd.sql

You can backup whole site folder with tar:

tar -czf /var/backup/html.tar.gz /var/www/html

Or mirror the directory:

rsync -Waq /var/www/html /var/backup/mirror/

Assuming our installation is in /var/www/html and original file ownership is apache.apache. Adjust to your current setting.

Use backslash “\” in front of cp command to prevent automatic interactive prompt for file replace.

cd /var/www/
wget https://wordpress.org/latest.zip
rm -rf html/wp-includes html/wp-admin
unzip latest.zip
mv wordpress/* html/
\cp -a wordpress/* html/
chown -R apache.apache /var/www/html
rm latest.zip

If SElinux is in use set the context as well

restorecon -R -v /var/www/html

Then launch upgrade php by going to your website address

https://yourdomain.com/wp-admin/upgrade.php

If things go deliciously wrong you can restore back quickly.

mysql -u <adminuser> -p wordpress < wordpress-yyyymmdd.sql

Restore with tar:

cd /var/www
rm -rf html
tar -xzf /var/backup/html.tar.gz

or rsync:

cd /var/www
rm -rf html
rsync -Waq /var/backup/mirror/html /var/www/

Check SElinux contexts and file ownerships as well and use chown + semanage from above if needed.

ls -alZ /var/www/html

That's all folks!

  • tips_and_howtos/wordpress_upgrade.txt
  • Last modified: 2022/03/27 10:09
  • by Pekka.Kuronen@pegasi.fi