You are here

db_restore.sh in Open Atrium 7.2

#!/bin/bash

# Configuration variables
backup_file="/opt/backups/oa-integration.sql"

# Check if file exists
if [ ! -f ${backup_file} ]; then
	  backup_file="/opt/development/integration/oa-integration.sql"
  fi

  # Check if file exists
  if [ ! -f ${backup_file} ]; then
	    echo "No backupfile exists, please run db_dump first."; exit 1
    fi

    cd ../drupal

    echo "Restoring db from ${backup_file}"

    # remove current tables
    `drush sql-connect` -e "show tables" -s | xargs -I "@@" `drush sql-connect` -e "DROP TABLE @@"

    # perform import
    `drush sql-connect` < ${backup_file}

    echo "Database restored."

File

scripts/db_restore.sh
View source
  1. #!/bin/bash
  2. # Configuration variables
  3. backup_file="/opt/backups/oa-integration.sql"
  4. # Check if file exists
  5. if [ ! -f ${backup_file} ]; then
  6. backup_file="/opt/development/integration/oa-integration.sql"
  7. fi
  8. # Check if file exists
  9. if [ ! -f ${backup_file} ]; then
  10. echo "No backupfile exists, please run db_dump first."; exit 1
  11. fi
  12. cd ../drupal
  13. echo "Restoring db from ${backup_file}"
  14. # remove current tables
  15. `drush sql-connect` -e "show tables" -s | xargs -I "@@" `drush sql-connect` -e "DROP TABLE @@"
  16. # perform import
  17. `drush sql-connect` < ${backup_file}
  18. echo "Database restored."