eyuprog

Bash Script Backup Restore Database

Jan 22nd, 2021
692
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. LOG_LOCATION=/var/log.txt
  2. rm backup.sql
  3.  
  4. mysqldump -h source_host -u"source_user" -p"source_password" "source_db" > backup.sql
  5.  
  6. action="$((mysql -h destination_host -u"destination_user" -p"destination_password" "destination_db" < backup.sql) 2>&1)"
  7. echo "Log " $(date +'%d-%m-%Y %H:%M:%S') "$action" >> $LOG_LOCATION
RAW Paste Data