Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Shell script for database and files site backup
# Database credentials
DB_USER=""
DB_PASS=""
DB_HOST=""
DB_NAME=""
# Database dump
mysqldump --user=$DB_USER --password=$DB_PASS --host=$DB_HOST $DB_NAME > $(date +"%d-%m-%Y").sql
# Files backup
tar -zcvf $(date +"%d-%m-%Y").tar.gz ..
# Cleanup
find ./* -mtime +30 -exec rm {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.