Skip to content

Instantly share code, notes, and snippets.

@nefigcas
Last active August 1, 2025 16:49
Show Gist options
  • Select an option

  • Save nefigcas/ff91a336501df941c1c482e5638311bf to your computer and use it in GitHub Desktop.

Select an option

Save nefigcas/ff91a336501df941c1c482e5638311bf to your computer and use it in GitHub Desktop.
MySQL/MariaDB database backup script for crontab
#!/bin/bash
db_name="your_database_name"
fecha=$(date +"%Y%m%d%H%M%S")
rutarespaldo="/the/path/Where_you-want-to-store-the/DB/${db_name}.${fecha}"
mysqldump --column-statistics=0 -u root "${db_name}" > "${db_name}.${fecha}.sql"
zip -m "${rutarespaldo}.zip" "${db_name}.${fecha}.sql"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment