daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest May 23rd, 2018 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. domains=(somedomain.com)
  3. sqldbs=(application_production)
  4.  
  5. usernames=(root)
  6. passwords=(password)
  7.  
  8. dreamhost_user=(d_user)
  9. dreamhost_server=(d.host.com)
  10.  
  11.  
  12. opath=$HOME/backups/database/
  13.  
  14. mysqlhost=localhost
  15.  
  16. suffix=$(date +%m-%d-%Y-%H-%M)
  17.  
  18. for (( i = 0 ; i < ${#domains[@]} ; i++ ))
  19. do
  20.     cpath=$opath${domains[$i]}
  21.     if [ -d $cpath ]
  22.     then
  23.         filler="just some action to prevent syntax error"
  24.     else
  25.         echo Creating $cpath
  26.         mkdir -p $cpath
  27.     fi
  28.     SQLFILE=${cpath}/${sqldbs[$i]}_$suffix.sql.gz
  29.  
  30.     mysqldump -c -h $mysqlhost --user ${usernames[$i]} --password=${passwords[$i]} ${sqldbs[$i]} | gzip > $SQLFILE
  31.  
  32.   rsync -aP --protocol=29  ~/backups/database/ ${dreamhost_user}@${dreamhost_server}:~/backups/database  
  33.  
  34.   rm ~/backups/database/somedomain.com/*
  35.  
  36.  
  37.     rsync -aP --protocol=29 ~/public_html/somedomain.com/shared/attachments ${dreamhost_user}@${dreamhost_server}:~/backups/files/somedomain.com/attachments/${suffix}
  38.  
  39.  
  40.     if [ $? -eq 0 ]
  41.     then
  42.         printf "%s was backed up successfully to %s" ${sqldbs[$i]} $SQLFILE
  43.         printf "Files were successfully backed up"
  44.     else
  45.         printf "WARNING: An error occured while attempting to backup %s to %s" ${sqldbs[$i]} $SQLFILE
  46.     fi
  47.    
  48.  
  49.    
  50. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top