Refresh data from prod to staging - sparc-request/research-master-id GitHub Wiki

On staging

crontab -u deploy -e # Comment out all the jobs    
cd /var/www/rails/research_master_id/current
RAILS_ENV=production bundle exec bin/delayed_job stop

On prod

mysqldump -u <prod_user> -p<prod_pass> -h <prod_host> <prod_db> | gzip > rmid_prod_$(date +%Y%m%d).sql.gz
scp rmid_prod_*.sql.gz deploy@<staging_host>:/tmp/

On staging

mysql -u <stage_user> -p<stage_pass> -h <stage_host> -e "DROP DATABASE IF EXISTS <stage_db>;"
mysql -u <stage_user> -p<stage_pass> -h <stage_host> -e "CREATE DATABASE <stage_db> CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
gunzip < /tmp/rmid_prod_*.sql.gz | mysql -u <stage_user> -p<stage_pass> -h <stage_host> <stage_db>
rm /tmp/rmid_prod_*.sql.gz  
cd /var/www/rails/research_master_id/current
RAILS_ENV=production bundle exec bin/delayed_job start
crontab -u deploy -e # uncomment all the jobs
⚠️ **GitHub.com Fallback** ⚠️