Answers for "Create a backup of the current database (~/current-db.sql in this example) and restore the database with the content in the backup"

0

Create a backup of the current database (~/current-db.sql in this example) and restore the database with the content in the backup

mysqldump \
  --user="$(wp config get DB_USER)" \
  --password="$(wp config get DB_PASSWORD)" \
  --host="$(wp config get DB_HOST | awk -F ":" '{print $1}')" \
  "$(wp config get DB_NAME)" > ~/current-db.sql
find ~/backup-BACKUP_DATE/sql/ -name '*.sql' | awk '{ print "source",$0 }' | mysql \
  --user="$(wp config get DB_USER)" \
  --password="$(wp config get DB_PASSWORD)" \
  --host="$(wp config get DB_HOST | awk -F ":" '{print $1}')" \
  --database="$(wp config get DB_NAME)"
Posted by: Guest on August-21-2021

Code answers related to "Create a backup of the current database (~/current-db.sql in this example) and restore the database with the content in the backup"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language