mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
78 lines
2.0 KiB
Bash
Executable File
78 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
TARGET="/var/db/${APP_NAME}/backup"
|
|
|
|
mkdir -p "${TARGET}"
|
|
|
|
timestamp=$(date +"%Y%m%d%H%M%S")
|
|
|
|
echo -n "* Generating database backup..." >&2
|
|
dst="${TARGET}/postgresql-dump-${timestamp}.pgdump"
|
|
touch "$dst" && chmod 0640 "$dst"
|
|
pg_dump -Fc $DATABASE_URL > $dst
|
|
|
|
echo " done" >&2
|
|
echo "$dst"
|
|
|
|
if [ -d "$SVN_REPOSITORIES" ]; then
|
|
dst="${TARGET}/svn-repositories-${timestamp}.tar.gz"
|
|
touch "$dst" && chmod 0640 "$dst"
|
|
echo -n "* Generating SVN repositories backup..." >&2
|
|
if tar czf "$dst" -C "${SVN_REPOSITORIES}" . ; then
|
|
echo " done" >&2
|
|
echo "$dst"
|
|
else
|
|
echo " failed" >&2
|
|
fi
|
|
else
|
|
echo "* No SVN repositories folder. Ignoring." >&2
|
|
fi
|
|
|
|
if [ -d "$GIT_REPOSITORIES" ]; then
|
|
dst="${TARGET}/git-repositories-${timestamp}.tar.gz"
|
|
touch "$dst" && chmod 0640 "$dst"
|
|
echo -n "* Generating Git repositories backup..." >&2
|
|
if tar czf "$dst" -C "${GIT_REPOSITORIES}" . ; then
|
|
echo " done" >&2
|
|
echo "$dst"
|
|
else
|
|
echo " failed" >&2
|
|
fi
|
|
else
|
|
echo "* No Git repositories folder. Ignoring." >&2
|
|
fi
|
|
|
|
# Use ATTACHMENTS_STORAGE_PATH value when OPENPROJECT_ATTACHMENTS__STORAGE__PATH is not set
|
|
export OPENPROJECT_ATTACHMENTS__STORAGE__PATH=${OPENPROJECT_ATTACHMENTS__STORAGE__PATH:-$ATTACHMENTS_STORAGE_PATH}
|
|
unset ATTACHMENTS_STORAGE_PATH
|
|
|
|
if [ -d "$OPENPROJECT_ATTACHMENTS__STORAGE__PATH" ]; then
|
|
dst="${TARGET}/attachments-${timestamp}.tar.gz"
|
|
touch "$dst" && chmod 0640 "$dst"
|
|
echo -n "* Generating attachments backup..." >&2
|
|
if tar czf "$dst" -C "${OPENPROJECT_ATTACHMENTS__STORAGE__PATH}" . ; then
|
|
echo " done" >&2
|
|
echo "$dst"
|
|
else
|
|
echo " failed" >&2
|
|
fi
|
|
else
|
|
echo "* No attachments folder. Ignoring." >&2
|
|
fi
|
|
|
|
if [ -d "/etc/${APP_NAME}" ]; then
|
|
dst="${TARGET}/conf-${timestamp}.tar.gz"
|
|
touch "$dst" && chmod 0640 "$dst"
|
|
echo -n "* Saving configuration..." >&2
|
|
if tar czf "$dst" -C /etc/${APP_NAME} installer.dat conf.d ; then
|
|
echo " done" >&2
|
|
echo "$dst"
|
|
else
|
|
echo " failed" >&2
|
|
fi
|
|
else
|
|
echo "* no configuration folder. Ignoring." >&2
|
|
fi
|