Skip to content

Instantly share code, notes, and snippets.

@mrded
Created January 18, 2016 20:22
Show Gist options
  • Save mrded/93d8d3b032d93849f4d8 to your computer and use it in GitHub Desktop.
Save mrded/93d8d3b032d93849f4d8 to your computer and use it in GitHub Desktop.
Drupal: backup script
#!/bin/bash
USER='root'
PASS='root'
DATABASE='drupal'
# Create folders if it's not yet.
mkdir -p ~/backups/{database,files}
# Backup.
mysqldump -u$USER -p$PASS $DATABASE | gzip -9 > ~/backups/database/$DATABASE-`date +"%d-%m-%Y"`.sql.gz
tar -czvf ~/backups/files/files-`date +"%d-%m-%Y"`.tar.gz /var/www/html/drupal/sites/default/files
# Delete backups older than 30 days.
find ~/backups/* -mtime +30 -exec rm {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment