If you like to keep your ddl backed up in some source management tool like svn or cvs and want to do it individually for stored procedures, events, triggers, tables and such rather than having a single file you can easily do so using the below. You could even include the –skip-dump-date or –skip-comments and use the below to compare ddl daily checking for alterations thus making sure you are aware of any ddl changes done on the database.
  user=backup_user
  password=`cat ~/.backup_password`
  hostname=127.0.0.1
  port=3306
  dbname=test_db
  path=/home/mysql/ddl
  date=`date +%Y%m%d`
  
  mysqldump -u$user -p$password -h$hostname -P$port
  --no-create-info --no-data --no-create-db --skip-opt $dbname >
  "$path"/"$dbname"_triggers_"$date".sql
  mysqldump -u$user -p$password -h$hostname -P$port --routines
  --skip-triggers --no-create-info --no-data --no-create-db
  --skip-opt $dbname > …