{"id":4190,"date":"2019-05-26T10:17:24","date_gmt":"2019-05-26T10:17:24","guid":{"rendered":"http:\/\/www.ipsych.me\/?p=4190"},"modified":"2019-05-26T10:20:23","modified_gmt":"2019-05-26T10:20:23","slug":"how-to-backup-automatically-scinote-deployed-in-local-server","status":"publish","type":"post","link":"https:\/\/www.ipsych.me\/?p=4190","title":{"rendered":"How to backup automatically SciNote deployed in local server"},"content":{"rendered":"<ol>\n<li>Install drivesync in ubuntu. (https:\/\/github.com\/MStadlmeier\/drivesync)<\/li>\n<li>Make Sync.sh Script as below.#! \/usr\/bin\/env bash<br \/>\nCd \/home\/$username\/Scinote<br \/>\ndocker exec scinote_db_production pg_dump -h localhost -p 5432 -U postgres -d scinote_production -c -b -f \/home\/db.bak<br \/>\ndocker cp scinote_db_production:\/home\/db.bak \/home\/$username\/Documents\/drive\/Backup\/SciNote\/Files\/<br \/>\ndocker cp scinote_web_production:\/usr\/src\/app\/public\/system \/home\/$username\/Documents\/drive\/Backup\/SciNote\/Files\/cd \/home\/$username\/Downloads\/drivesync<\/p>\n<p>ruby drivesync.rb<\/li>\n<li>chmod +x Sync.sh<\/li>\n<li>Automate using Crontab.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h1 id=\"\u6062\u590d\u6570\u636e\">Data recovery<\/h1>\n<p>If you are restoring data on another host, you need to\u00a0copy the\u00a0backup\u00a0<code>config\/application.yml<\/code>and\u00a0<code>production.env<\/code>files to the corresponding location.<\/p>\n<h2 id=\"\u6062\u590dpostgresql\u6570\u636e\u5e93\">Restore postgresql database<\/h2>\n<ul>\n<li>Copy data to container:<br \/>\n<code>docker cp db.bak scinote_db_production:\/home\/db.bak<\/code><\/li>\n<li>Enter the container of scinote_db_production and execute<br \/>\n<code>psql -h localhost -p 5432 -U postgres -d scinote_production -f \/home\/db.bak<\/code><br \/>\n<code>docker cp ~\/Documents\/sciweb-data-bak\/system\/. scinote_web_production:\/usr\/src\/app\/public\/system\/<\/code><br \/>\n<code>make docker-production<\/code><\/li>\n<\/ul>\n<h2 id=\"\u6062\u590d\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u6570\u636e\">Recover data in the file system<\/h2>\n<ul>\n<li>Copy data to container:<br \/>\n<code>docker cp \/your\/bakup\/path\/ scinote_web_production:\/usr\/src\/app\/public\/system<\/code><\/li>\n<\/ul>\n<h2 id=\"\u66f4\u65b0\u6e90\u6587\u4ef6\">Update source file<\/h2>\n<ol>\n<li>Rebuild the docker image:\u00a0<code>make docker-production<\/code><\/li>\n<li>Migrate data:\n<ul>\n<li><code>make cli-production<\/code><\/li>\n<li><code>rails db:migrate<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Restart docker container<br \/>\n<code>docker-compose -f .\/docker-compose.production.yml up -d<\/code><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>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\/drivesync ruby drivesync.rb chmod +x Sync.sh Automate using Crontab. &nbsp; &nbsp; Data recovery If you are restoring [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4190","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.ipsych.me\/index.php?rest_route=\/wp\/v2\/posts\/4190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ipsych.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ipsych.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ipsych.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ipsych.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4190"}],"version-history":[{"count":2,"href":"https:\/\/www.ipsych.me\/index.php?rest_route=\/wp\/v2\/posts\/4190\/revisions"}],"predecessor-version":[{"id":4192,"href":"https:\/\/www.ipsych.me\/index.php?rest_route=\/wp\/v2\/posts\/4190\/revisions\/4192"}],"wp:attachment":[{"href":"https:\/\/www.ipsych.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ipsych.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ipsych.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}