Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.11 KB | None | 0 0
  1. echo Welcome to this backup script on $(date).
  2. echo first we are going to create rar files for each domain.
  3. cd /
  4. cd var
  5. cd www
  6. cd vhosts
  7. echo We are now in the right directory, now rar will be executed... This will take a long time.
  8. for folder in */; do rar a -m0 -r "${folder%/}.rar" "$folder"; done
  9. echo Process complete. Moving files to temp space.
  10. mv *.rar /root/backup/files
  11. echo Moving completed.
  12. echo Changing working directory
  13. cd /
  14. cd root
  15. cd backup
  16. cd sql
  17. echo Working directory changed.
  18. echo Commencing MySQL backup...
  19. # Optional variables for a backup script
  20. MYSQL_USER="admin"
  21. MYSQL_PASS=`cat /etc/psa/.psa.shadow`
  22. BACKUP_DIR=/root/backup/sql/$(date +%F);
  23. test -d "$BACKUP_DIR" || mkdir -p "$BACKUP_DIR"
  24. # Get the database list, exclude information_schema
  25. for db in $(mysql -B -s -u $MYSQL_USER --password=$MYSQL_PASS -e 'show databases' | grep -v information_schema)
  26. do
  27.   # dump each database in a separate file
  28.   echo Making backup of database "$db".
  29.         mysqldump -u $MYSQL_USER --password=$MYSQL_PASS "$db" | gzip > "$BACKUP_DIR/$db.sql.gz"
  30. done
  31. echo Done backupping all databases.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement