Skip to content

Latest commit

 

History

History
63 lines (33 loc) · 2.08 KB

DEPLOY.md

File metadata and controls

63 lines (33 loc) · 2.08 KB

Deployment of the CommonBike app

1. Server configuration

  1. Create a VPS
  2. Set up git hook
  3. Configure nginx

2. Deployment from localhost to server

First, add the server as remote branch.

git remote add deploy [email protected]:/var/app/commonbike

Now choose: where do you want to deploy?

  1. To the test environment, test.common.bike?

    git push deploy branch-you-want-to-deploy:develop

  2. To production, common.bike?

    git push deploy branch-you-want-to-deploy:master

Wait a few minutes before the branch is fully deployed. Result: a new deployment!

3. Backup the mongo database

There are two ways.

1. Using data folder snapshots

You can create a backup of a MongoDB deployment by making a copy of MongoDB’s underlying data files (docs).

So, to backup the mongo db:

rsync -avz [email protected]:/usr/share/commonbike_mdb ~/backup-mongodb

So, to restore the mongo db:

rsync -avz ~/backup-mongodb/commonbike_mdb/* [email protected]:~/backup-mongodb

NOTE: Since copying multiple files is not an atomic operation, you must stop all writes to the mongod before copying the files.

2. Using mongodump and mongorestore

An easy way to do mongodb backups on the server is using [mongodump](https://docs.mongodb.com/manual/reference/program/mongodump/#bin.mongodump) and [mongorestore](https://docs.mongodb.com/manual/reference/program/mongorestore/#bin.mongorestore).

First log in to the server:

Log in into the Docker container used for mongo:

docker exec -it deploy_db_1 bash

Backup the database:

mongodump -h 127.0.0.1 --port 27017 --out /data/backup/20180101 -d commonbike

If you want to restore the database in a later stage:

mongorestore -h 127.0.0.1 --port 27017 /data/backup/20180101 -d commonbike