Mercurial > hg > Members > anatofuz > growiBackup
changeset 1:b8ad430d968d
add run.sh
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 16 Dec 2020 15:05:07 +0900 (2020-12-16) |
parents | aa664e434d43 |
children | cfb93034ed39 |
files | backup.go run.sh |
diffstat | 2 files changed, 28 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/backup.go Wed Dec 16 14:07:18 2020 +0900 +++ b/backup.go Wed Dec 16 15:05:07 2020 +0900 @@ -14,14 +14,20 @@ // Revision is growy entry struct type Revision struct { - ID string `json:"_id"` - Format string `json:"format"` - CreatedAt time.Time `json:"createdAt"` - Path string `json:"path"` - Body string `json:"body"` - Author string `json:"author"` - HasDiffToPrev bool `json:"hasDiffToPrev"` - V int `json:"__v"` + ID struct { + Oid string `json:"$oid"` + } `json:"_id"` + Format string `json:"format"` + CreatedAt struct { + Date time.Time `json:"$date"` + } `json:"createdAt"` + Path string `json:"path"` + Body string `json:"body"` + Author struct { + Oid string `json:"$oid"` + } `json:"author"` + HasDiffToPrev bool `json:"hasDiffToPrev"` + V int `json:"__v"` } // Revisions is as equal as revision.json @@ -47,7 +53,7 @@ path2Revision := make(map[string]Revision) for _, rev := range *revs { if prevRev, ok := path2Revision[rev.Path]; ok { - if prevRev.CreatedAt.After(rev.CreatedAt) { + if prevRev.CreatedAt.Date.After(rev.CreatedAt.Date) { path2Revision[rev.Path] = rev } continue
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run.sh Wed Dec 16 15:05:07 2020 +0900 @@ -0,0 +1,13 @@ +DAY=`date "+%Y-%m-%d"` +REVJSON=revision_back_${DAY}.json +cd /home/ie-user/backup +docker exec growi_mongo_1 mongoexport -d growi -c revisions --pretty --jsonArray --out ${REVJSON} +docker cp growi_mongo_1:${REVJSON} . +docker exec growi_mongo_1 rm ${REVJSON} +./growibackup ${REVJSON} Growi +ls *.json | grep -v ${REVJSON} | xargs rm + +cd Growi +hg add . +hg commit -u 'autobackup' -m "backup ${DAY}" +hg push