Skip to content

Commit

Permalink
Merge pull request #35 from lucascbeyeler/dev
Browse files Browse the repository at this point in the history
Fix for Issue #34 and more
  • Loading branch information
lucascbeyeler authored Apr 21, 2017
2 parents 43c0cb6 + 65071cc commit 935c38d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Enter inside the folder zmbackup and execute the script install.sh. Follow the i

```
$ zmbackup -v
zmbackup version: 1.1.2
zmbackup version: 1.1.3
```

Open the folder /etc/cron.d/zmbackup.cron and adjust each job scheduled to the time you want the execution. If you configured zmbkpose or any old release before, please undo and use this file for scheduling.
Expand Down
36 changes: 33 additions & 3 deletions src/zmbackup
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
################################################################################
# zmbackup:
#
# 18/04/2017 - Version 1.1.2 - By Lucas Costa Beyeler
# 18/04/2017 - Version 1.1.3 - By Lucas Costa Beyeler
# <[email protected]>
# <[email protected]>
################################################################################
Expand Down Expand Up @@ -207,6 +207,10 @@ list_sessions ()
;;
"distlist") printf "\n Type: Distribution List Backup\n"
;;
"alias") printf "\n Type: Alias Backup\n"
;;
"ldap") printf "\n Type: Account Backup - Only LDAP\n"
;;
esac
done
echo ""
Expand Down Expand Up @@ -365,6 +369,32 @@ backup_alias()
fi
}

# Backup all the accounts - only LDAP entry
backup_ldap()
{
export SESSION="ldap-"$(date +%Y%m%d%H%M%S)
if [ -z $1 ]; then
build_backup_list $ACOBJECT $ACFILTER
else
for i in $(echo "$1" | sed 's/,/\n/g'); do
echo $i >> $TEMPACCOUNT
done
fi
if ! [ -s $TEMPACCOUNT ]; then
echo "Nothing to do"
else
notify_email_begin $SESSION
echo "SESSION: $SESSION started on $(date)" >> $TEMPSESSION
cat $TEMPACCOUNT | parallel --no-notice --env --jobs '$MAX_PARALLEL_PROCESS' \
'loop_ldap_backup {} "$ACOBJECT"'
echo "SESSION: $SESSION completed in $(date)" >> $TEMPSESSION
mv "$TEMPDIR" "$WORKDIR/$SESSION" && rm -rf "$TEMPDIR"
cat $TEMPSESSION >> $WORKDIR/sessions.txt
echo "$(date) - Backup completed for all accounts" >> $LOGFILE
notify_email_finish "OK" $SESSION
fi
}

# Backup all the accounts - PARALLEL_SUPPORT
backup_full()
{
Expand Down Expand Up @@ -513,7 +543,7 @@ case "$1" in
backup_alias $3
;;
"-ldp"|"--ldap" )
ldap_bkp $3
backup_ldap $3
;;
* )
backup_full $2
Expand Down Expand Up @@ -628,7 +658,7 @@ case "$1" in
show_help
;;
"-v"|"--version" )
echo "zmbackup version: 1.1.2"
echo "zmbackup version: 1.1.3"
;;
* )
show_help
Expand Down

0 comments on commit 935c38d

Please sign in to comment.