Skip to content

Database backup and restore

Abdelrahman Elkady edited this page Mar 31, 2016 · 3 revisions

Database backups and restores are handled through a simple bash script, you can find a template into the codebase in bash-scripts/database.template.sh

The current script supports only one database dump and restore, modify it if needed to dump multiple databases at once

After copying the script template you will need to modify the following :

  • REMOTE : The default remote that the script would connect to (e.g. root@123.456.78.90)
  • DUMP_NAME : Replace with the dump name (e.g. dump_`date "+%F_%R"`)
  • DATABASE_NAME : Your database name, a sub-directory inside your dump directory (e.g. sems)

Usage :

  • Make the script executable $ chmod +x bash-scripts/database.sh
  • This script should run from your Local Machine
  • Running the script without any arguments would backup the database from the default remote provided

Backup :

  • Remove any old dumps in ~/backups/
  • Run $ bash-scripts/database.sh <remote> <backup or b>
  • The dump is located into your local home folder under ~/backups

Restore :

  • Put your dump folder on your local machine under ~/backups
  • Run $ bash-scripts/database.sh <remote> <restore or r>
  • Tada ! 🎉
Clone this wiki locally