Backup WordPress HTML files and Database with Timestamp

How to backup database and files for WordPress is easy with the commands below.

$ cd /home/user/html

Backup the database with wp

$ wp db export
Success: Exported to 'a51c5fbc_import-2023-08-13-2dceb88.sql'.

cd ..

tar -czf html-backup-$(date +%F).tar.gz html

Now you have a timestamped backup of wordpress with the database

ls -lah html-backup-2023-08-13.tar.gz 
-rw-rw-r-- 1 a51c5fbc a51c5fbc 67M Aug 13 17:25 html-backup-2023-08-13.tar.gz

Leave a Comment