How to restore the mongodb?

From PheonixSolutions
Jump to navigation Jump to search

How to restore the mongodb

1. Copy backup file from Aws s3 bucket

  aws s3 cp s3://taxary/db_backups/db_backups-2022-01-17-0000.tar.gz .
  tar -xvf db_backups-2022-01-17-0000.tar.gz
 mongorestore root/db_backups-2022-01-17-0000

2. Deploy frontend:
Path: /var/www/taxary_fe

 cd /var/www/taxary_fe
npm i
npm run build


After running the “npm run build”, “public” folder will be generated in /var/www/taxary_fe directory. Copy /var/www/taxary_fe/build path and add it as the document root in web server config.

3. Install apache and Create config file accordingly. Install the SSL certificate for frontend and backend domains. Please find the FE and API config file below.


Ex:- taxary-be.conf

 
<VirtualHost *:80>
ServerName api.taxary.tk
ServerAlias www.api.taxary.tk
ServerAdmin admin-mail@localhost
DocumentRoot /var/www/taxary
Alias /kyc /var/www/taxary/public/kyc/
<Directory /var/www/taxary/public/kyc>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order deny,allow
allow from all
Require all granted
</Directory>
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/taxary>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
# NodeJS integration
ProxyPass / http://api.taxary.tk:4006/
ProxyPassReverse / api.taxary.tk:4006/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


Ex:- taxary-fe.conf

 
<VirtualHost *:80>
ServerName taxary.tk
ServerAlias www.taxary.tk
ServerAdmin admin-mail@localhost
DocumentRoot /var/www/taxary_fe/build
<Directory /var/www/taxary_fe/build>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html to allow HTML5 state links
RewriteRule ^ index.html [L]
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

4. Install certbot and SSL with the below command

 certbot --apache -d api.taxary.tk

5. Inorder to renew the SSL certificate automatically add the below one in crontab -e

 30 14 * * * sudo certbot renew