Created
February 11, 2016 17:41
-
-
Save chrisfree/c0113dfae5f1958d42d2 to your computer and use it in GitHub Desktop.
Backup a Drupal site to Amazon S3 using Drush
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
# Switch to the docroot. | |
cd /var/www/yourProject/docroot/ | |
# Backup the database. | |
drush sql-dump --gzip --result-file=/home/yourJenkinsUser/db-backups/yourProject-`date +%F-%T`.sql.gz | |
# Switch to the backups directory. | |
cd /home/yourJenkinsUser/db-backups/ | |
# Store the recently created db's filename as a variable. | |
database=$(ls -t | head -n1) | |
# Upload to Amazon S3, using s3cmd (https://github.com/s3tools/s3cmd). | |
s3cmd put $database s3://yourBucketName/$database | |
# Delete databases older than 10 days. | |
find /home/yourJenkinsUser/db-backups/ -mtime +10 -type f -delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment