mysqldump backup utility of MySQL/MariaDB supports the export of metadata or specifically creating DDL scripts with the option –no-data.
$ mysqldump -uroot -p test --no-data --routines --events --triggers > test_ddl.sql
Note: Remember to mention the –routines, –events and –triggers also to export the related objects.