3 CentOS 7 Backup and restore proceedure
bartmika edited this page Apr 25, 2019
·
1 revision
The goal of this article is to help setup the various backup / restore solutions for this project.
While you are on the CentOS 7 server, please login as the administrator and then run the following in your console:
- Go inside postgres.
su - postgres
- Export out database.
pg_dump -U postgres -d academicstoday_db > academicstoday_db.backup
- Exit postgres.
exit
- Move our export to our
django
user.
mv /var/lib/pgsql/academicstoday_db.backup /home/techops/academicstoday_db.backup
- Delegate authority for the administrator to manage the exported database.
chown techops /home/techops/academicstoday_db.backup;
chgrp techops /home/techops/academicstoday_db.backup;
- Log in as the administrator and confirm the database export was successful.
su - techops
cd ~/
ls -alh
- Congradulations you've exported a copy of the database.
The following instructions will work Linux
or MacOS
.
- Download the database (Mac/Linux)
scp -i ~/.ssh/id_rsa techops@academicstoday.ca:/home/techops/academicstoday_db.backup /var/tmp
-
Congradulations you've saved a copy of the database onto your local machine.
-
Confirm your copy.
ls -alh /var/tmp
- Load up the
postgres
app (we are assuming you are running Postgres.app) and run the following. Please ensure you do not run thedrop
command in your production environment!
drop database academicstoday_db;
create database academicstoday_db;
- Open
Terminal
and run the following:
psql -U django academicstoday_db < /var/tmp/academicstoday_db.backup;
- Congradulations you've restored the production environment data onto your local machine. Now before you run your application, please run the following backfill command.
(env)$ python manage.py backfill