The one liner below will create a backup directory in the parent directory, and place the backup within a directory created using today's date.

One thing to note, we are excluding non needed data from this backup like the WordPress uploads folder since its not affected when you run updates to WordPress core, plugins or themes.

The database will be backed up as well.

Make sure to run this within the root directory of the WordPress install.

mkdir -p ../backup/$(date +%Y-%m-%d) ; mysqldump $(grep DB_NAME wp-config.php | grep -v WP_CACHE_KEY_SALT | cut -d \' -f 4) | gzip > ../backup/$(date +%Y-%m-%d)/db.sql.gz ; rsync -ahv --exclude 'wp-content/uploads' --exclude 'wp-content/cache' . ../backup/$(date +%Y-%m-%d)/

Did this answer your question?