ããã¼ç¨éã® mLab ã§ãªã¢ã¼ãããã¯ã¢ãããã
ç°å¢
- MongoDB 3.2.11
- dbxcli 1.4.0
- heroku-toolbelt 3.43.15
- heroku-buildpack-mongodb Rev. 59b9e8d
- heroku-buildpack-dbxcli Rev. d67845a
ã¢ããã¼ã·ã§ã³
ããã¼ç¨éã® Heroku ã¢ããªã§ mLab ã¢ããªã³ã Sandbox ãã©ã³ã§å©ç¨ãã¦ããã
mLab ã® DB ã®ããã¯ã¢ãã㯠Sandbox ãã©ã³ã§ã¯æä¾ãããªãã®ã§ããªã¢ã¼ãããã¯ã¢ãããè¨å®ãããã
ããã¼ç¨éãªã®ã§ãã§ããã°ãéããããªãç¯å²ã§è¡ãããã
heroku-buildpack-mongodb
Heroku ã® buildpack ã« MongoDB ã®ãã¤ããªã使ããããã«ãã heroku-buildpack-mongodb ãããã®ã§ãããã使ã£ã¦ Heroku Scheduler 㧠mongodump ãå¼ã³åºãã°ãããã¯ã¢ããã¯åãããã§ããã
ã¹ãã¬ã¼ã¸
åé¡ã¯ã¹ãã¬ã¼ã¸ãã©ããããã§ããã
æ®éã«èããã S3 ã ããããã¼ç¨é㧠AWS ã¯ãã¾ã使ããããªããIAM ã MFA ãªã©ãèãããã¨ãå¤ãããã ã
ãã㧠Dropbox ãå©ç¨ãããã¨ãèããã
dbxcli ã¨ããã¯ã³ãã¤ããªã§ Dropbox ãæä½ã§ãããã¼ã«ã Heroku Scheduler ãã使ããã°è¯ãããã ã
heroku-buildpack-dbxcli
ã¨ãããã¨ã§ heroku-buildpack-dbxcli ã¨ãã Buildpack ãä½ã£ãã
ãã® Buildpack ã使ãã°ãdbxcli ã Heroku ä¸ããç°¡åã«ä½¿ããã¨ãã§ããã
Heroku è¨å®
ã¾ãã¯ä»¥ä¸ã®ãã㪠backup.sh ãä½ã£ã¦ git commit ãã¦ããã
#!/bin/sh # backup xxx $ mongodump -h xxx.mongolab.com --port xxx -d heroku_appxxx -u heroku_appxxx -p xxx -o xxx_dump --excludeCollection=system.users # archive $ tar cvzf xxx_dump.tgz xxx_dump # upload to Dropbox $ dbxcli put xxx_dump.tgz Backups/xxx_dump.tgz
次ã«ãã® Git ãªãã¸ããªã Heroku ã« push ããã
$ heroku create --buildpack http://github.com/goodeggs/heroku-buildpack-mongodb.git $ heroku buildpacks:add --index 2 http://github.com/mallowlabs/heroku-buildpack-dbxcli.git $ heroku config:add DROPBOX_AUTH_TOKEN=<your token> $ git push heroku master
Dropbox ã®ãã¼ã¯ã³ã¯ãæå 㧠dbxcli ã§ä¸åº¦ãã°ã¤ã³ã㦠~/.config/dbxcli/auth.json ã®å 容ãè¦ã¦åå¾ãã(ã¡ãã£ã¨ãã£ãæªã)ã
ãã¨ã¯ backup.sh ã Heroku Scheduler ããå¼ã³åºãã°ãDropbox ã« mongodump ã®çµæãä¿åãããããã«ãªãã
ã¾ã¨ã
- dbxcli ã¯ä¾¿å©ï¼
- Heroku Buildpacks ã便å©ï¼