Upgrade All WordPress Sites on a Linux Server with a Single Command

Minor WordPress releases are often installed automatically, but major versions usually need to be updated manually. If you only manage one or two sites, logging into the admin area and updating them one by one is no big deal. But once a server is hosting dozens or hundreds of WordPress sites, doing that manually becomes painful very quickly.

In practice, a WordPress version upgrade mostly means replacing wp-admin, wp-includes, and the root files other than wp-config.php. During a dashboard update, WordPress only downloads the changed files. Once you understand that, it becomes possible to update many sites in bulk by copying the new core files over each installation.

find /home/wwwroot -mindepth 1 -maxdepth 1 -type d | xargs -n 1 cp /tmp/wp/* -frap

In this example, /home/wwwroot is the directory containing all of the WordPress sites on the server, and /tmp/wp contains the updated core files that should be copied into each installation.

For safety, delete the wp-content directory from the extracted WordPress package before copying, because that directory contains themes, plugins, uploads, and other site-specific custom files. Overwriting it blindly could destroy important data.

This kind of one-command upgrade is not something most WordPress users need, but if you manage large numbers of sites on the same server, it can save an enormous amount of time.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *