Skip to content

WP Backup (Manual)

This is an excellent and thorough manual backup procedure! It covers the two essential components: files and database. ✅

Here is a regeneration of the response, maintaining the structure and content while offering the next logical step:


💾 Manually Backing Up Your WordPress Site

This method is reliable, especially for local development and testing. It ensures you have copies of both your file system and your database.

🗂️ 1. Copy WordPress Files

Your WordPress files are typically located in the webroot directory: /srv/http/wordpress.

These files include:

  • Core WordPress files
  • wp-content folder (containing themes, plugins, and media uploads)
  • wp-config.php (containing crucial database connection information)

To create a dated backup:

cp -r /srv/http/wordpress ~/wordpress-backups/site-$(date +%F)

This command creates a complete file backup in your home directory, named like ~/wordpress-backups/site-2025-10-04.

Or

tar -czvf wordpress-files-$(date +%F).tar.gz /srv/http/wordpress
This command creates a compressed file backup in your home directory, named like ~/wordpress-backups/site-2025-10-04.tar.gz.


🗄️ 2. Export the Database

Your site's dynamic content (posts, pages, settings, users, etc.) is stored in a MySQL database.

To back up the database:

mysqldump -u root -p wordpress > ~/wordpress-backups/db-$(date +%F).sql

(Note: Replace wordpress with your actual database name if it is different.)


♻️ 3. To Restore Later

If your site encounters issues or you need to migrate it, you can restore using these backups:

# Restore files
cp -r ~/wordpress-backups/site-YYYY-MM-DD /srv/http/wordpress

# Restore database
mysql -u root -p wordpress < ~/wordpress-backups/db-YYYY-MM-DD.sql

(Remember to substitute YYYY-MM-DD with the actual date of the backup you wish to restore.)


🧠 Tip: Automation

You can significantly improve this process by automating the file copying and database export with a simple bash script that runs daily or weekly via cron. This makes backups effortless and consistent.

Would you like me to show you how to make that automatic backup script?