Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Info | ||
---|---|---|
| ||
If you are considering a backup strategy for Production Data, do consider storing the backup offsite. A geographically different location ensures that events like flooding or fire, don't destroy all the backups too! |
To perform an full backup of all Bahmni Databases, one can use the following command in bahmni-environment/scripts:
Clone the repo bahmni-environment from the URL: https://github.com/Bahmni/bahmni-environment to obtain the scripts for this purpose.
To backup the MySQL instance:
Code Block | ||||
---|---|---|---|---|
| ||||
bahmni-environment/scripts/backup-mysql.sh [db_password] [backup_dir]
# eg. bahmni-environment/scripts/backup-mysql.sh mYp@ssw0rd /tmp/backup |
To backup the PostgreSQL instance:
Code Block | ||||||
---|---|---|---|---|---|---|
| sudo ./backup-all-dbs.sh -b
| |||||
bahmni-environment/scripts/backup-pgsql.sh [backup_dir]
# eg. bahmni-environment/scripts/backup-pgsql.sh /tmp/backup |
If you want to setup an automated schedule to backup, then you can create a crontab entry to trigger this command periodically. For example:
Code Block | ||||
---|---|---|---|---|
| ||||
# Edit the crontab file of root user crontab -u root -e # Make entry as (for running twice a day at 2PM, and 10PM) 00 14,22 * * * sudo bahmni-environment/Project/scripts/backup-mysql.sh [db_password] [backup_dir] 00 14,22 * * * sudo bahmni-environment/scripts/backup-pgsql.sh [backup-all-dbs.sh -b_dir] # eg. 00 14,22 * * * sudo bahmni-environment/scripts/backup-mysql.sh mYp@ssw0rd /tmp/backup # eg. 00 14,22 * * * sudo bahmni-environment/scripts/backup-pgsql.sh /tmp/backup |
Info | ||
---|---|---|
| ||
cron may fail silently for above command on some installations, since we use the sudo command in our scripts. To enable sudo commands to run in cron, you need to disable requiretty. Run visudo command, and comment out the line: Defaults requiretty For more details on this read: http://unix.stackexchange.com/questions/49077/why-does-cron-silently-fail-to-run-sudo-stuff-in-my-script |
Code Block | ||||
---|---|---|---|---|
| ||||
# Add this entry in crontab to delete files older than 15 days from /backup folder (every evening at 6 PM) 00 18 * * * /usr/bin/find /backup -type f -mtime +15 -exec /bin/rm -f {} \; |
For more examples on crontab entries read this: crontab
To restore DB, use the following commands (ensure tomcat & openerp services are Stopped): ; also ensure that the following services are stopped before running:
- If you have installed with the older shell script based installers, tomcat, openerp and apache must be stopped.
- If you have installed via the new RPM based installers, openerp, openmrs, bahmni-lab and apache must be stopped.
- Once restored, restart the corresponding services again.
Code Block | ||||
---|---|---|---|---|
| ||||
###################################
# One shot restore command:
###################################
sudo ./restore-all-dbs.sh -m /backup/mysql-dump.sql.gz -p /backup/pgsql-dump.sql.gz
###################################
# Or individual restore commands:
###################################
# Unzip the backups:
gzip -d [filename.gz]
# Restore MYSQL (script is in bahmni-environment)
./scripts/restore-mysql.sh [mysql-backup-filename]
# Restore Postgres (script is in bahmni-environment)
./scripts/restore-pgsql.sh [pgsql-backup-filename]
# If pgsql restore fails because of open connections, then you can restart postgres by executing:
sudo /etc/rc.d/init.d/postgresql-9.2 stop
sudo /etc/rc.d/init.d/postgresql-9.2 start |
Panel | ||||||
---|---|---|---|---|---|---|
| ||||||