Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell: added shell helpers for pushd/popd #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions backups/zimbra-common.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -468,3 +468,11 @@ function zimbraCreateDataFolder() {

execZimbraCmd cmd | hideReturnedId
}

function shellQuietPopd() {
command popd > /dev/null
Copy link
Owner

@jvaubourg jvaubourg Aug 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why it would be better to use command in front of popd/pushd rather than to use directly popd/pushd?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jvaubourg
It's only in order to run a shell command ignoring any shell functions (like alias, …)

}

function shellQuietPushd() {
command pushd "$@" > /dev/null
}
8 changes: 4 additions & 4 deletions borgbackup/zimbra-borg-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ function borgBackupMain() {
cp -a "${_borg_local_folder_configs}" "${_borg_local_folder_tmp}/borg/"

log_info "Sending data to Borg (new archive ${new_archive} in the main repo)"
pushd "${_borg_local_folder_tmp}" > /dev/null
shellQuietPushd "${_borg_local_folder_tmp}"
borg create ${_borg_debug_mode} --compression lz4 "${_borg_repo_main}::{now:%Y-%m-%d}" . || {
log_err "The backup on the Borg server is *NOT* up do date"
}
popd > /dev/null
shellQuietPopd
fi
else
log_err "The Borg server or the main repository is currently unusable"
Expand Down Expand Up @@ -258,11 +258,11 @@ function borgBackupAccount() {
zimbra-backup.sh ${backup_options} -d "${_debug_mode}" -e all_except_accounts -b "${_borg_local_folder_tmp}" -m "${email}"

log_info "${email}: Sending data to Borg (new archive ${new_archive} in the account repo)"
pushd "${_borg_local_folder_tmp}/accounts/${email}" > /dev/null
shellQuietPushd "${_borg_local_folder_tmp}/accounts/${email}"
borg create ${_borg_debug_mode} --stats --compression lz4 "${borg_repo}::{now:%Y-%m-%d}" . || {
log_err "${email}: The backup on the Borg server is *NOT* up do date"
}
popd > /dev/null
shellQuietPopd
fi
else
log_err "${email}: The Borg server or the repository is currently unusable for this account"
Expand Down