Tecadmin published a shell script to backup your Magento 2 installation and database.
Magento 2 Codebase & Database Backup Script
This tutorial will help you to automate the Magento2 codebase and database backup process using a shell script. The script will perform automatic backups on a scheduled interval. The script also has the ability to remove older backups as per configuration.
Magento 2 Codebase & Database Backup Script