Skip to content

Instantly share code, notes, and snippets.

@ngstigator
Last active April 21, 2018 16:46
Show Gist options
  • Save ngstigator/81ec7c2e6a8af64eda094d652124260a to your computer and use it in GitHub Desktop.
Save ngstigator/81ec7c2e6a8af64eda094d652124260a to your computer and use it in GitHub Desktop.
bash script create db subdir and backup to it
#!/bin/bash
# create {year} folder if it doesn't exist
mkdir -p /home/web/db/$(date +%Y)
# dump database into {year} folder
mysqldump --opt -uweb -pPASSWORD DATABASE_NAME | gzip > /home/web/db/$(date +%Y)/DATABASE_NAME_$(date +%Y%m%d-%H%M).sql.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment