SHARE
TWEET

s3cmd backup script

Sushubh Mar 1st, 2016 33 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. t=`date -Iseconds`
  4.  
  5. cd /home/username/s3
  6. mkdir ${t}
  7. echo "using temporary location $(pwd)/${t} to back up files"
  8.  
  9. echo "dumping domainname database"
  10. mysqldump --single-transaction --quick --lock-tables=false -u databaseuser -pdatabasepassword -h mysql.username.co domainname > ${t}/domainname.sql
  11. pigz --fast ${t}/domainname.sql
  12.  
  13. echo "dumping domainname files"
  14. tar zcf /home/username/s3/${t}/domainname.tar.gz /home/username/domainname.co/
  15.  
  16. echo "shipping all files to amazon s3!"
  17. /usr/local/bin/s3cmd sync -r ${t} s3://bucket.name/domainname/
  18.  
  19. echo "deleting temporary folder"
  20. rm -r ${t}
RAW Paste Data
Top