Skip to content

Commit 9d93d96

Browse files
authored
Merge pull request #7 from silinternational/develop
Configure CodeShip
2 parents 1431d99 + 5513521 commit 9d93d96

File tree

8 files changed

+64
-19
lines changed

8 files changed

+64
-19
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.aes
2+
codeship-services.yml
3+
codeship-steps.yml
4+
dockercfg

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ local.env
99

1010
vendor/
1111
*.aes
12+
13+
dockercfg

README.md

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# mysql-backup-restore
2-
Service to backup and/or restore mysql databases using S3
2+
Service to backup and/or restore mysql databases to/from S3
33

44
## How to use it
55
1. Create an S3 bucket to hold your backups
@@ -8,34 +8,45 @@ Service to backup and/or restore mysql databases using S3
88
4. Run a backup and check your bucket for that backup
99

1010
### Environment variables
11-
`MODE=[backup|restore]`
11+
`MODE` Valid values: `backup`, `restore`
1212

13-
`DB_NAMES=name1 name2 name3 ...`
13+
`DB_NAMES` list of the database names
1414

15-
`MYSQL_USER=`
15+
`MYSQL_USER` user that accesses the database
1616

17-
`MYSQL_PASSWORD=`
17+
`MYSQL_PASSWORD` password for the `MYSQL_USER`
1818

19-
`MYSQL_DUMP_ARGS=` (optional) additional arguments to the mysqldump command, e.g., `--max_allowed_packet=50M`
19+
`MYSQL_DUMP_ARGS` (optional) additional arguments to the mysqldump command, e.g., `--max_allowed_packet=50M`
2020

21-
`AWS_ACCESS_KEY=` used for S3 interactions
21+
`AWS_ACCESS_KEY` used for S3 interactions
2222

23-
`AWS_SECRET_KEY=` used for S3 interactions
23+
`AWS_SECRET_KEY` used for S3 interactions
2424

25-
`S3_BUCKET=` _e.g., s3://database-backups_ **NOTE: no trailing slash**
25+
`S3_BUCKET` e.g., _s3://database-backups_ **NOTE: no trailing slash**
2626

2727
>**It's recommended that your S3 bucket have versioning turned on.**
2828
2929
## Docker Hub
30-
This image is built automatically on Docker Hub as [silintl/mysql-backup-restore](https://hub.docker.com/r/silintl/mysql-backup-restore/)
30+
This image is built automatically on Docker Hub as [silintl/mysql-backup-restore](https://hub.docker.com/r/silintl/mysql-backup-restore/).
3131

3232
## Playing with it locally
33-
You'll need [Docker](https://www.docker.com/get-docker) and [Make](https://www.gnu.org/software/make/)
34-
35-
1. `cp local.env.dist local.env` and supply variables
36-
2. Ensure you have a `gz` dump in your S3 bucket to be used for testing. A test database is provided as part of this project in the `test` folder.
37-
3. `make`
38-
39-
A UI into the local database will then be running at [http://localhost:8001](http://localhost:8001)
40-
41-
A couple of test databases are provided in the `test` folder if needed.
33+
You'll need [Docker](https://www.docker.com/get-docker), [Docker Compose](https://docs.docker.com/compose/install/), and [Make](https://www.gnu.org/software/make/).
34+
35+
1. cd .../mysql-backup-restore
36+
2. mkdir ./mybackups
37+
3. cp -p test/world.sql.gz ./mybackups
38+
4. `make db` # creates the MySQL DB server
39+
5. `make restore` # restores the DB dump file
40+
6. `docker ps -a` # get the Container ID of the exited restore container
41+
7. `docker logs <containerID>` # review the restoration log messages
42+
8. `make backup` # create a new DB dump file
43+
9. `docker ps -a` # get the Container ID of the exited backup container
44+
10. `docker logs <containerID>` # review the backup log messages
45+
11. `make restore` # restore the DB dump file from the new backup
46+
12. `docker ps -a` # get the Container ID of the exited restore container
47+
13. `docker logs <containerID>` # review the restoration log messages
48+
14. `make clean` # remove containers and network
49+
15. `docker volume ls` # find the volume ID of the MySQL data container
50+
16. `docker volume rm <volumeID>` # remove the data volume
51+
17. `docker images` # list existing images
52+
18. `docker image rm <imageID ...>` # remove images no longer needed

codeship-services.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
app:
2+
build:
3+
image: silintl/mysql-backup-restore
4+
dockerfile: ./Dockerfile
5+
cached: true

codeship-steps.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
- name: push_branch
2+
service: app
3+
type: push
4+
image_name: silintl/mysql-backup-restore
5+
image_tag: "{{.Branch}}"
6+
exclude: (master|main|snyk*)
7+
registry: https://index.docker.io/v1/
8+
encrypted_dockercfg_path: dockercfg.encrypted
9+
10+
- name: push_latest
11+
service: app
12+
type: push
13+
image_name: silintl/mysql-backup-restore
14+
image_tag: "latest"
15+
tag: main
16+
registry: https://index.docker.io/v1/
17+
encrypted_dockercfg_path: dockercfg.encrypted

dockercfg.encrypted

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
codeship:v2
2+
BScPjmqUw7hFx9ZW8TpjL9cIXw+1Faw6Xo/kOFPyh8Lr6qoSnpqL9wU/OW2yObPm9igjCqTxCIDWfCE/5sr3qVo2RCI2cI73zrRIyUReJrORwIVc0wxGauwi3ctj5zSCSlNOcTI5SoY736UhZ1XIPLeHnwI1Y/eA3MRG9D2inlf2VsZNgw0D2pddTMRfQVzSmz4dPGg2MceRSqUjf+cGomfBiW/ZXNih7jNl+2DlwD5s/fJBYk+OKfPnwoq6/no489YZBksMttfZtkt/2KG+teiXCB/gJ43OUYhj6jucZP36RHpkcjTbD+uJ88VJ

test/README

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The example database was originally downloaded from the web and placed
2+
in this directory. You can find the original here:
3+
4+
https://dev.mysql.com/doc/world-setup/en/

test/employees.sql.gz

-33.7 MB
Binary file not shown.

0 commit comments

Comments
 (0)