Skip to content
Snippets Groups Projects
Verified Commit a9e5968f authored by psy's avatar psy
Browse files

do not backup or mail emtpy pads

parent d15b385e
No related branches found
No related tags found
No related merge requests found
......@@ -24,18 +24,23 @@ while read -r pad owner; do
continue
fi
logger -t hedgedoc-util "Processing pad $pad";
logger -t hedgedoc-util "Processing pad $pad"
if [ "$BACKUP_ENABLED" = true ]; then
hedgedoc-util pad get-content $pad > $BACKUP_PATH/$(date +"%Y%m%d")_$pad.md && logger -t hedgedoc-util "backup successfull"
fi
content=$(hedgedoc-util pad get-content $pad)
if [ -z $(sed 's/[[:blank:]]//g' <<< "$content") ]; then
logger -t hedgedoc-util "pad is empty"
else
if [ "$BACKUP_ENABLED" = true ]; then
printf "%s" "$content" > $BACKUP_PATH/$(date +"%Y%m%d")_$pad.md && logger -t hedgedoc-util "backup successfull"
fi
if [ "$MAIL_ENABLED" = true ]; then
hedgedoc-util pad mail --convert dokuwiki --convert markdown --template $MAIL_TEMPLATE $pad && logger -t hedgedoc-util "mailed successfull"
if [ "$MAIL_ENABLED" = true ]; then
hedgedoc-util pad mail --convert dokuwiki --convert markdown --template $MAIL_TEMPLATE $pad && logger -t hedgedoc-util "mailed successfull"
fi
fi
hedgedoc-util pad delete $pad && \
logger -t hedgedoc-util "Pad $pad deleted";
hedgedoc-util pad delete $pad && logger -t hedgedoc-util "Pad $pad deleted"
done < <(hedgedoc-util --output tsv-noheader pad list -c id -c ownerId --last-change-older $RETENTION_DAYS)
if [ "$BACKUP_ENABLED" = true ]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment