Skip to content

Commit 566eb05

Browse files
michaellzcreevejd
authored andcommitted
Add option to upload archive to IBM COS (#2)
1 parent 635f5c5 commit 566eb05

File tree

5 files changed

+108
-26
lines changed

5 files changed

+108
-26
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: bash
22
services: docker
33
env:
4-
secure: AYO9a/roP4bf1YyZHUd4Y7ap4QZqmCK/++1MF8u3RVtIlPcjm8DvN5+7RwvXJeDreWpaK3eewYvP18/ZS5ot04m+y1MF1XgI1HueDqnynCkHtNPxOqjfbkcxCmOvwE3oW5MapbbIV7jcP0ZEAUM3IMHgqLs/E/0QC3sHEG8NaIZbMQ/LH/zuTTX7ZN55b9BURn4jJZWitcmS7NHDPpNJxOWXsYozA7tdnodAzjqXbWyGmDOnC3jBWyZdKEjA/94+sgDGH0XnpEDDuItaNGpPTRCGL3CaLsCdzj05ZD6Sjug2g7b7jpRNgiu5ca+l07IJuImNXkgpE71NOf4CxDLjFU26QEzy4Mx//yU2B1aIM4NELpuDjDgdL1qg3P0xufRH3oGO8pknrQ5JsciCZil2+3iVOZqdXT6F4wueFDjiCOP20iMaHi0NXknsrumdS1K/yDTEb2Z0kj79Yn/+JKpHfP12np1BKMMW2ZQzHcxoQLQNXHXTJCxcQmcuUU7WsAvWaA8Onsga6E+/KoDaHbSruT11OwfddOtIZMAgoSyx0CZVt+SxxUiqbo28u/TEq1ics4zVTzfY/zV88gDGA4lLPx9cDwktwBSpmvFFl6SrB0hsFFJNYN02675XnAwMzftc8mwarxt3vIJg5qrbSpMQGUgwjOsM8EBqSPzbZoUzcog=
4+
secure: FUab7+Hp6ev10T7m/zq9MN9B0ReGOdNSE7xrgx9YsA4zDsIwezEnoo1uh1M4RQGnV0OAvclNdNdv5ggGV91ij64ETpKTX6NUev9MO8zdOWw0wMrSi9/AOP0lbKH/M52IQs60zD+fJ9StHqt7DP6krfIjHa0/0YmhZKynQn7dNwI4rriZVOUuveYvVOATA7HGdDDHLqlUN6sUEjLlUpe2WkqmB1EDwgioVGe59slvlIZ9nUKHlRHFIacA2W93RO/o4DuHjjbYJZy1Lw7aWZ3yF3VO3S6tHvuw1Q1daT2mBrnNl3K+SMAJI1BqtfEXtA9Zu8t8Hb42XbGWzvsPwU1nP46InK6+wz15/A49KOFtGwMfVfg5uPon565sQ3vPqxSJ/QxHtGB2GsgfmTlxbuOgY6hKNwh1qWMlWiIaCFFf6++rnDT4ZLVMg3t9mp4tQDqMxASRAiX5X4CFte3oOjeOWAHIxbHa39cQ7wAWpmEptU4RJlyuXhjJp0W4NjuD9KqmgxizYJO8uCUkOfHBGH2BpicqxF6hWnGe0/fJm/JSuQjsGs1SPgcQIvHanrbeAEIIrrkQSnxClxsFxXWLxWTiRei3N/q5wb9/Ew4GfhUV49i8YzgE+wa/AIYO/PWGIaQWjF4sYo59CJaiM7ES/e2NdPcxL+1QDEMuVNsHT7X0/pM=
55
addons:
66
apt:
77
packages:

CHANGELOG.md

Lines changed: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,106 @@
11
# Change Log
2+
23
All notable changes to this project will be documented in this file.
34

45
The format is based on [Keep a Changelog](http://keepachangelog.com/)
56
and this project adheres to [Semantic Versioning](http://semver.org/).
67

78
## [Unreleased][]
89

10+
## [1.1.0][] - 2019-05-24
11+
12+
### Added
13+
14+
- Added `monsoon-upload-cos` plugin to upload backup files to IBM Cloud Object Storage
15+
916
## [1.0.1][] - 2018-04-06
17+
1018
### Fixed
11-
- Fixed conflicting package version declarations.
19+
20+
- Fixed conflicting package version declarations.
1221

1322
## [1.0.0][] - 2018-04-06
23+
1424
### Added
15-
- New mandatory parameter: `SOFTLAYER_NETWORK` to choose between
16-
`public` and `private` for upload.
25+
26+
- New mandatory parameter: `SOFTLAYER_NETWORK` to choose between
27+
`public` and `private` for upload.
1728

1829
### Updated
19-
- Updated MySQL, Postgres, and MySQL modules.
20-
- Updated Sentry Raven from `5.32.0` to `6.6.0`
30+
31+
- Updated MySQL, Postgres, and MySQL modules.
32+
- Updated Sentry Raven from `5.32.0` to `6.6.0`
2133

2234
### Fixed
23-
- Fixed linter errors.
35+
36+
- Fixed linter errors.
2437

2538
## [0.3.2][] - 2017-12-20
39+
2640
### Fixed
27-
- Made plugins fail with non-zero status for backup errors
28-
- Bumped Python from `2.7.13` to `2.7.14`
29-
- Switched to modern multi-stage build process
41+
42+
- Made plugins fail with non-zero status for backup errors
43+
- Bumped Python from `2.7.13` to `2.7.14`
44+
- Switched to modern multi-stage build process
3045

3146
## [0.3.1][] - 2017-07-17
47+
3248
### Fixed
33-
- Also skip Softlayer upload if missing username or api key
49+
50+
- Also skip Softlayer upload if missing username or api key
3451

3552
## [0.3.0][] - 2017-07-11
53+
3654
### Added
37-
- PostgreSQL support
38-
- `/backups` Docker volume
55+
56+
- PostgreSQL support
57+
- `/backups` Docker volume
3958

4059
### Changed
41-
- Use `bash` instead of `ash`
42-
- Local backups go to `/backups`, not `/tmp`
60+
61+
- Use `bash` instead of `ash`
62+
- Local backups go to `/backups`, not `/tmp`
4363

4464
### Fixed
45-
- Apply updates for `db` and `ncurses`
65+
66+
- Apply updates for `db` and `ncurses`
4667

4768
## [0.2.1][]
69+
4870
### Fixed
49-
- Name files `.gz` rather than `.gzip` to avoid `gunzip` issues
71+
72+
- Name files `.gz` rather than `.gzip` to avoid `gunzip` issues
5073

5174
## [0.2.0][]
75+
5276
### Added
53-
- You can skip backing up Mongo, MySQL, or files by not specifying
54-
Mongo host, MySQL host, or file paths
55-
- Softlayer credentials are still required, and Sentry is still optional
77+
78+
- You can skip backing up Mongo, MySQL, or files by not specifying
79+
Mongo host, MySQL host, or file paths
80+
- Softlayer credentials are still required, and Sentry is still optional
5681

5782
## [0.1.7][]
83+
5884
### Fixed
59-
- Wait for backups to complete
85+
86+
- Wait for backups to complete
6087

6188
## [0.1.6][]
89+
6290
### Fixed
63-
- OS package security updates
91+
92+
- OS package security updates
6493

6594
## 0.1.0
95+
6696
### Added
67-
- Mongo, MySQL, and file backup
68-
- Upload to Softlayer
69-
- Travis CI for continuous integration
7097

71-
[Unreleased]: https://github.ibm.com/bdu/gamora/compare/1.0.1...HEAD
98+
- Mongo, MySQL, and file backup
99+
- Upload to Softlayer
100+
- Travis CI for continuous integration
101+
102+
[unreleased]: https://github.ibm.com/bdu/gamora/compare/1.1.0...HEAD
103+
[1.1.0]: https://github.ibm.com/bdu/gamora/compare/1.0.1...1.1.0
72104
[1.0.1]: https://github.ibm.com/bdu/gamora/compare/1.0.0...1.0.1
73105
[1.0.0]: https://github.ibm.com/bdu/gamora/compare/0.3.2...1.0.0
74106
[0.3.2]: https://github.ibm.com/bdu/gamora/compare/0.3.1...0.3.2

docker-compose.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ services:
2929
- SOFTLAYER_CONTAINER
3030
- SOFTLAYER_PATH
3131

32+
# IBM Cloud Object Storage config
33+
- IBM_COS_ACCESS_KEY
34+
- IBM_COS_SECRET_KEY
35+
- IBM_COS_INSTANCE_ID
36+
- IBM_COS_ENDPOINT_URL
37+
- IBM_COS_BUCKET
38+
- IBM_COS_PATH
39+
3240
- BACKUP_LOCAL_PATHS
3341
links:
3442
- mysql

gamora/docker-entrypoint.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ upload_backup() {
2121

2222
if [[ -z "${SOFTLAYER_PATH:-}" ]]; then
2323
log "Skipping upload because no Softlayer path"
24+
upload_backup_cos "${filename:?}"
2425
return
2526
fi
2627

2728
if [[ -z "${SOFTLAYER_USER:-}" ]]; then
2829
log "Skipping upload because no Softlayer user"
30+
upload_backup_cos "${filename:?}"
2931
return
3032
fi
3133

3234
if [[ -z "${SOFTLAYER_API_KEY:-}" ]]; then
3335
log "Skipping upload because no Softlayer api key"
36+
upload_backup_cos "${filename:?}"
3437
return
3538
fi
3639

@@ -49,6 +52,44 @@ upload_backup() {
4952
log "Done: Uploading backup"
5053
}
5154

55+
upload_backup_cos() {
56+
local filename=$1
57+
local remote_path
58+
59+
if [[ -z "${IBM_COS_INSTANCE_ID:-}" ]]; then
60+
log "Skipping upload because no IBM COS service instance id"
61+
return
62+
fi
63+
64+
if [[ -z "${IBM_COS_ENDPOINT_URL:-}" ]]; then
65+
log "Skipping upload because no IBM COS endpoint url"
66+
return
67+
fi
68+
69+
if [[ -z "${IBM_COS_BUCKET:-}" ]]; then
70+
log "Skipping upload because no IBM COS bucket name"
71+
return
72+
fi
73+
74+
if [[ -z "${IBM_COS_PATH}" ]]; then
75+
remote_path="$(date +%Y/%m)"
76+
else
77+
remote_path="${IBM_COS_PATH:?}/$(date +%Y/%m)"
78+
fi
79+
80+
log "Uploading backup to IBM COS"
81+
monsoon "${NOTIFICATION_SETTINGS[@]}" upload cos \
82+
--endpoint-url "${IBM_COS_ENDPOINT_URL}" \
83+
--instance-id "${IBM_COS_INSTANCE_ID}" \
84+
--access-key "${IBM_COS_ACCESS_KEY}" \
85+
--secret-key "${IBM_COS_SECRET_KEY}" \
86+
"${BACKUP_PATH:?}/${filename:?}" \
87+
"${IBM_COS_BUCKET:?}" \
88+
"${remote_path:?}" \
89+
&& rm -f "${BACKUP_PATH:?}/${filename:?}"
90+
log "Done: Uploading backup to IBM COS"
91+
}
92+
5293
back_up_mongo() {
5394
local filename
5495

gamora/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ monsoon-backup-mysql==0.1.7
77
monsoon-backup-postgresql==0.1.5
88
monsoon-notifier-sentry==0.1.4
99
monsoon-upload-softlayer==0.2.0
10+
monsoon-upload-cos==0.1.0

0 commit comments

Comments
 (0)