How to backup a WordPress site via SSH
To make a complete local backup of a remote WordPress install over SSH, you need to perform two distinct steps:
- Download the files (using
rsync). - Export and download the database (using
mysqldumppiped throughssh).
Here is the step-by-step guide.
Prerequisites- SSH Access: You need the
username,host(IP or domain), andpassword(or SSH key) for the remote server. - WordPress Path: You need to know where WordPress is installed (e.g.,
/var/www/htmlor/home/user/public_html). - Database Credentials: You will need the database name, user, and password. (I will show you how to find these below).
If you don't know your database login details, run this command to read them from your remote wp-config.php file: ssh user@remote-server.com "cat /path/to/wordpress/wp-config.php" | grep 'DB_'
Note the DB_NAME, DB_USER, and DB_PASSWORD for Step 2.