How to backup automatically SciNote deployed in local server
- Install drivesync in ubuntu. (https://github.com/MStadlmeier/drivesync)
- 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/drivesyncruby drivesync.rb
- chmod +x Sync.sh
- Automate using Crontab.
Data recovery
If you are restoring data on another host, you need to copy the backup config/application.yml
and production.env
files 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
- Rebuild the docker image:
make docker-production
- Migrate data:
make cli-production
rails db:migrate
- Restart docker container
docker-compose -f ./docker-compose.production.yml up -d