forked from 0k/0k-charms
Browse Source
new: [rsync-backup-target] add rotated logs for ssh validation and each rsync session
new: [rsync-backup-target] add rotated logs for ssh validation and each rsync session
Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>pull/1/head
Valentin Lab
4 years ago
4 changed files with 115 additions and 8 deletions
-
7rsync-backup-target/build/Dockerfile
-
38rsync-backup-target/build/src/usr/local/sbin/ssh-cmd-validate
-
67rsync-backup-target/hooks/log_rotate-relation-joined
-
11rsync-backup-target/metadata.yml
@ -0,0 +1,67 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
## Should be executable N time in a row with same result. |
||||
|
|
||||
|
. lib/common |
||||
|
|
||||
|
set -e |
||||
|
|
||||
|
uid=$(docker_get_uid "$SERVICE_NAME" "rsync") |
||||
|
|
||||
|
|
||||
|
LOGS=/var/log/rsync |
||||
|
mkdir -p "$SERVICE_DATASTORE/$LOGS" |
||||
|
touch "$SERVICE_DATASTORE/$LOGS/ssh-cmd-validate.log" |
||||
|
chown -v "$uid" "$SERVICE_DATASTORE/$LOGS" "$SERVICE_DATASTORE/$LOGS/ssh-cmd-validate.log" |
||||
|
|
||||
|
rotated_count=$(relation-get rotated-count 2>/dev/null) || true |
||||
|
rotated_count=${rotated_count:-52} |
||||
|
|
||||
|
|
||||
|
## XXXvlab: a lot of this intelligence should be moved away into ``logrotate`` charm |
||||
|
DST="$CONFIGSTORE/$TARGET_SERVICE_NAME/etc/logrotate.d/$SERVICE_NAME" |
||||
|
file_put "$DST" <<EOF |
||||
|
/var/log/docker/$SERVICE_NAME/ssh-cmd-validate.log |
||||
|
{ |
||||
|
weekly |
||||
|
missingok |
||||
|
dateext |
||||
|
dateyesterday |
||||
|
dateformat _%Y-%m-%d |
||||
|
extension .log |
||||
|
rotate $rotated_count |
||||
|
compress |
||||
|
delaycompress |
||||
|
notifempty |
||||
|
create 640 $uid |
||||
|
sharedscripts |
||||
|
} |
||||
|
|
||||
|
/var/log/docker/$SERVICE_NAME/target_*_rsync.log |
||||
|
{ |
||||
|
weekly |
||||
|
missingok |
||||
|
dateext |
||||
|
dateyesterday |
||||
|
dateformat _%Y-%m-%d |
||||
|
extension .log |
||||
|
rotate $rotated_count |
||||
|
compress |
||||
|
delaycompress |
||||
|
notifempty |
||||
|
create 640 |
||||
|
sharedscripts |
||||
|
} |
||||
|
EOF |
||||
|
|
||||
|
config-add "\ |
||||
|
services: |
||||
|
$MASTER_TARGET_SERVICE_NAME: |
||||
|
volumes: |
||||
|
- $DST:/etc/logrotate.d/docker-${SERVICE_NAME}:ro |
||||
|
- $SERVICE_DATASTORE$LOGS:/var/log/docker/$SERVICE_NAME:rw |
||||
|
$MASTER_BASE_SERVICE_NAME: |
||||
|
volumes: |
||||
|
- $SERVICE_DATASTORE$LOGS:$LOGS:rw |
||||
|
|
||||
|
" |
@ -1,3 +1,14 @@ |
|||||
description: Backup Rsync over SSH Target |
description: Backup Rsync over SSH Target |
||||
data-resources: |
data-resources: |
||||
- /var/mirror |
- /var/mirror |
||||
|
- /var/log/rsync |
||||
|
|
||||
|
uses: |
||||
|
log-rotate: |
||||
|
#constraint: required | recommended | optional |
||||
|
#auto: pair | summon | none ## default: pair |
||||
|
constraint: required |
||||
|
auto: summon |
||||
|
solves: |
||||
|
unmanaged-logs: "in docker logs" |
||||
|
#default-options: |
Write
Preview
Loading…
Cancel
Save
Reference in new issue