Created
January 18, 2016 20:22
-
-
Save mrded/93d8d3b032d93849f4d8 to your computer and use it in GitHub Desktop.
Drupal: backup script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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