Skip to content

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Elias Oehen committed Mar 3, 2021
2 parents 4b9a7f9 + 2f116ac commit 06f46ce
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Ignore example backup files
example/backup/
example/remote/
example/log/

# Ignore environment variable file
example/.env
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ For using the cleanup feature attach the same `/backup` volume in the `bbtsoftwa
| latest | Latest master build | ![Size](https://shields.beevelop.com/docker/image/image-size/bbtsoftwareag/mssql-backup/latest.svg?style=flat-square) |
| 0.1.0 | Release [0.1.0](https://github.com/bbtsoftware/docker-mssql-backup/releases/tag/0.1.0) | ![Size](https://shields.beevelop.com/docker/image/image-size/bbtsoftwareag/mssql-backup/0.1.0.svg?style=flat-square) |
| 0.2.0 | Release [0.2.0](https://github.com/bbtsoftware/docker-mssql-backup/releases/tag/0.2.0) | ![Size](https://shields.beevelop.com/docker/image/image-size/bbtsoftwareag/mssql-backup/0.2.0.svg?style=flat-square) |
| 0.3.0 | Release [0.2.0](https://github.com/bbtsoftware/docker-mssql-backup/releases/tag/0.3.0) | ![Size](https://shields.beevelop.com/docker/image/image-size/bbtsoftwareag/mssql-backup/0.3.0.svg?style=flat-square) |
| 0.3.0 | Release [0.3.0](https://github.com/bbtsoftware/docker-mssql-backup/releases/tag/0.3.0) | ![Size](https://shields.beevelop.com/docker/image/image-size/bbtsoftwareag/mssql-backup/0.3.0.svg?style=flat-square) |
| 0.4.0 | Release [0.4.0](https://github.com/bbtsoftware/docker-mssql-backup/releases/tag/0.4.0) | ![Size](https://shields.beevelop.com/docker/image/image-size/bbtsoftwareag/mssql-backup/0.4.0.svg?style=flat-square) |

### Configuration

Expand Down
16 changes: 6 additions & 10 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,21 @@ cronSchedule=${CRON_SCHEDULE}
cronSchedule=${cronSchedule%\"}
cronSchedule=${cronSchedule#\"}

# Write log to stdout
cronLogConfig="> /proc/1/fd/1 2>&1 | tee -a $cronLogFile"

# Create crontab definition
if [[ $SMTP_HOST ]];
then
echo "Cron e-mail reporting activated. '${SMTP_HOST}'"
# (GH-39) Add (-a) paramter to append the log file, otherwise the log file is truncated every run.
# echo "$cronSchedule . /container_env.sh; /usr/local/bin/backup.sh 2>&1 | tee -a /var/log/cron.log | mail -s 'SQL Server Backup Result' $MAIL_TO 2>&1 | tee -a /var/log/cron.log" > /etc/cron.d/crontab.conf
echo "$cronSchedule . /container_env.sh; /usr/local/bin/backup.sh 2>&1 | tee /var/log/cron.log | mail -s 'SQL Server Backup Result' $MAIL_TO 2>&1 | tee /var/log/cron.log" > /etc/cron.d/crontab.conf
echo "$cronSchedule . /container_env.sh; /usr/local/bin/backup.sh $cronLogConfig | mail -s 'SQL Server Backup Result' $MAIL_TO $cronLogConfig" > /etc/cron.d/crontab.conf
else
# (GH-39) Add (-a) paramter to append the log file, otherwise the log file is truncated every run.
# echo "$cronSchedule . /container_env.sh; /usr/local/bin/backup.sh 2>&1 | tee -a /var/log/cron.log" > /etc/cron.d/crontab.conf
echo "$cronSchedule . /container_env.sh; /usr/local/bin/backup.sh 2>&1 | tee /var/log/cron.log" > /etc/cron.d/crontab.conf
echo "$cronSchedule . /container_env.sh; /usr/local/bin/backup.sh $cronLogConfig" > /etc/cron.d/crontab.conf
fi

# Apply cron job
crontab /etc/cron.d/crontab.conf

# Create the log file to be able to run tail
touch /var/log/cron.log

echo "Starting cron task manager..."
echo " - Crontab = $cronSchedule"
cron && tail -f /var/log/cron.log
cron -f
16 changes: 15 additions & 1 deletion example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ which contains the standard AdventureWorks2019 database from microsoft for backu

## Preconditions

The follow precondition is required for using this examples.
The follow precondition is required for using this examples on a desktop.

* Installation of [Docker Desktop](https://www.docker.com/products/docker-desktop) Software.
* `Docker Desktop` must switch to linux containers.

**NOTE:**
[Docker Engine](https://docs.docker.com/engine/) provides .deb and .rpm packages for Linux distribution

## Environment variable

Rename a copy of the template file `.env.template` to `.env` and modify the values of the environment variables.
Expand All @@ -30,6 +33,17 @@ To run this example container execute the command:

`docker-compose up`

## Logging

The backup container cron job write logs to stdout and stderr output streams. Docker containers emit logs to the stdout
and stderr output streams. Because containers are stateless, the logs are stored on the Docker host in JSON files by default.

`docker logs [Container]`

**NOTE:**
The log file location can get with follow docker command:
`docker inspect --format='{{.LogPath}}' [container-id or container-name]`

## Test backup file cleanup

How to modify a backup file `lastwritetime` file setting, to test the backup file cleanup function.
Expand Down
1 change: 0 additions & 1 deletion example/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ services:
context: ../
volumes:
- ./backup:/backup
- ./log:/var/log
- ./remote:/remote
- ../backup.sh:/usr/local/bin/backup.sh
environment:
Expand Down
Empty file removed example/log/.gitkeep
Empty file.

0 comments on commit 06f46ce

Please sign in to comment.