plumwd

Website Backup

Dec 2nd, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.62 KB | None | 0 0
  1. domain=( mydomain.com )
  2. opath=$HOME/backup/
  3. webdir=$HOME/mydir.com
  4. today=$(date +%m-%d-%Y)
  5.  
  6. for (( i = 0; i < ${#domain[@]}; i++))
  7. do
  8.         cpath=$opath${domain[$i]}
  9.         if [ -d $cpath ]
  10.         then
  11.                 filler="just some action to prevent syntax error"
  12.         else
  13.                 echo Creating $cpath
  14.                 mkdir -p $cpath
  15.         fi
  16.         zip -r ${cpath}/"$today"_"$domain".zip $webdir
  17.  
  18. done
  19.  
  20. #use aws-cli to upload
  21. aws s3 sync $opath s3://mybucket/backups/ --exclude "$opath""*.sh"
  22.  
  23. #delete backup from web server
  24. find $HOME/backup/* -type d -exec rm -rf {} \; 2> /dev/null
Advertisement
Add Comment
Please, Sign In to add comment