CloudLinux.ro
Backup

How to back up a WordPress site, step by step

Updated 7/20/2026

A complete WordPress backup has two parts: the site files (themes, plugins and uploads in wp-content, plus wp-config.php) and the database. Here is how to save them.

1. Back up the files

cd /var/www/html
tar -czf /mnt/backup/wp-files-$(date +%F).tar.gz wp-content wp-config.php

2. Back up the database

Find the database name and user in wp-config.php:

mysqldump -u wp_user -p wordpress | gzip > /mnt/backup/wp-db-$(date +%F).sql.gz

3. Restore

Unpack the files back into the site folder and re-import the database:

gunzip < wp-db-2026-07-18.sql.gz | mysql -u wp_user -p wordpress

4. Automate with cron

0 3 * * * cd /var/www/html && tar -czf /mnt/backup/wp-files-$(date +\%F).tar.gz wp-content wp-config.php && mysqldump -u wp_user -pPASSWORD wordpress | gzip > /mnt/backup/wp-db-$(date +\%F).sql.gz

Keep backups on a Backup Box

Mount a Backup Box as an extra disk and write the copies straight there. That way, if the server fails or a plugin breaks the site, you restore quickly from a safe copy. The address, username and password are on the Backup Box page in your panel.

apt-get install -y cifs-utils
mkdir -p /mnt/backup
mount -t cifs //BACKUP_BOX_ADDRESS/backup /mnt/backup -o username=USER,password=PASSWORD,vers=3.0

See also the guide The best VPS for WordPress.

Put this guide into practice on your own VPS

EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.

See pricing

Related tutorials