a guest Dec 6th, 2016 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. echo Welcome to this backup script on $(date).
  2. sleep 5
  3. echo first we are going to create rar files for each domain.
  4. cd /
  5. cd var
  6. cd www
  7. cd vhosts
  8. echo We are now in the right directory, now rar will be executed... This will take a long time.
  9. sleep 5
  10. #for folder in */; do rar a -m0 -r "${folder%/}.rar" "$folder"; done
  11. for folder in */; do rar a -m0 -r "${folder%/}.rar" "$folder"; done ;
  12. echo Process complete. Moving files to temp space.
  13. mv *.rar /root/backup/files
  14. echo Moving completed.
  15. echo Changing working directory
  16. cd /
  17. cd root
  18. cd backup
  19. cd sql
  20. echo Working directory changed.
  21. echo Commencing MySQL backup...
  22. # Optional variables for a backup script
  23. MYSQL_USER="admin"
  24. MYSQL_PASS=`cat /etc/psa/.psa.shadow`
  25. #BACKUP_DIR=/root/backup/sql/$(date +%F);
  26. BACKUP_DIR=/root/backup/sql/
  27. test -d "$BACKUP_DIR" || mkdir -p "$BACKUP_DIR"
  28. # Get the database list, exclude information_schema
  29. for db in $(mysql -B -s -u $MYSQL_USER --password=$MYSQL_PASS -e 'show databases' | grep -v information_schema)
  30. do
  31.   # dump each database in a separate file
  32.   echo Making backup of database "$db".
  33.         mysqldump -u $MYSQL_USER --password=$MYSQL_PASS "$db" | gzip > "$BACKUP_DIR/$db.sql.gz"
  34. done
  35. echo Done backupping all databases.
  36. echo Moving files to upload directory
  37. BACKUP=/root/backup/upload/$(date +%F);
  38. mkdir $BACKUP
  39. echo Moving rar files...
  40. mv /root/backup/files/* $BACKUP
  41. echo Done moving rar files
  42. echo Moving database files...
  43. mv /root/backup/sql/* $BACKUP
  44. echo Done moving database files
  45. echo Commencing FTP upload. This will take a long time
  46. ncftpput -R -v -u "" -p "XXXXXX" /home/ $BACKUP
  47. echo All done, cleaning up.
  48. rm -rf /root/backup/upload/*
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