How to backup automatically SciNote deployed in local server

  1. Install drivesync in ubuntu. (https://github.com/MStadlmeier/drivesync)
  2. Make Sync.sh Script as below.#! /usr/bin/env bash
    Cd /home/$username/Scinote
    docker exec scinote_db_production pg_dump -h localhost -p 5432 -U postgres -d scinote_production -c -b -f /home/db.bak
    docker cp scinote_db_production:/home/db.bak /home/$username/Documents/drive/Backup/SciNote/Files/
    docker cp scinote_web_production:/usr/src/app/public/system /home/$username/Documents/drive/Backup/SciNote/Files/cd /home/$username/Downloads/drivesync

    ruby drivesync.rb

  3. chmod +x Sync.sh
  4. Automate using Crontab.

 

 

Data recovery

If you are restoring data on another host, you need to copy the backup config/application.ymland production.envfiles to the corresponding location.

Restore postgresql database

  • Copy data to container:
    docker cp db.bak scinote_db_production:/home/db.bak
  • Enter the container of scinote_db_production and execute
    psql -h localhost -p 5432 -U postgres -d scinote_production -f /home/db.bak
    docker cp ~/Documents/sciweb-data-bak/system/. scinote_web_production:/usr/src/app/public/system/
    make docker-production

Recover data in the file system

  • Copy data to container:
    docker cp /your/bakup/path/ scinote_web_production:/usr/src/app/public/system

Update source file

  1. Rebuild the docker image: make docker-production
  2. Migrate data:
    • make cli-production
    • rails db:migrate
  3. Restart docker container
    docker-compose -f ./docker-compose.production.yml up -d

Leave a Reply

Your email address will not be published. Required fields are marked *