melaniedunford
9/12/2018 - 5:52 AM

Storing WordPress files and database with WP-CLI on the server.

Storing WordPress files and database with WP-CLI on the server.

#!/bin/sh

tar --create --gzip --verbose --absolute-names --file=./wp_backup-$(date +%Y-%m-%d-%H%M%S).tar.gz --exclude=*.tar.gz /var/www/websites/wp
#!/bin/sh

wp db export - | gzip > ./db_backup-$(date +%Y-%m-%d-%H%M%S).sql.gz
30 18 * * * sh /var/www/backups/backup.sh > /var/www/logs/cronlog 2>&1
#!/bin/sh

/usr/local/bin/wp db --path=/var/www/websites/wp - | gzip > /var/www/backups/db_backup-$(date +%Y-%m-%d-%H%M%S).sql.gz &
tar --create --gzip --absolute-names --file=/var/www/backups/wp_backup-$(date +%Y-%m-%d-%H%M%S).tar.gz --exclude=*.tar.gz /var/www/websites/wp

WordPress Backups with WP-CLI

Related tutorial: https://code64.de/visionerdy/wordpress-backups/