Skip to content

Instantly share code, notes, and snippets.

@Tomasz-Silpion
Created January 28, 2017 02:07
Show Gist options
  • Save Tomasz-Silpion/145f6e3114f8a9a41b3637e2b2c3e7af to your computer and use it in GitHub Desktop.
Save Tomasz-Silpion/145f6e3114f8a9a41b3637e2b2c3e7af to your computer and use it in GitHub Desktop.
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