You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB

#!/bin/bash
# Author: Tealk
# Repo: https://codeberg.org/Tealk/shell-administration-script
# shellcheck disable=SC2034
title="Create backup"
error=false
printf " %b %s..." "${INFO}" "${title}"
if [ -d "${FULLPATH}" ]; then
if [ -d "${FULLPATH}"_bak ]; then
rm -r "${FULLPATH}"_bak
fi
if [ ! -d "${FULLPATH}"_bak ]; then
if [ "$1" = "git" ]; then
if ! cp -r "${FULLPATH}" "${FULLPATH}"_bak; then
reason="can't create file backup"
error=true
ERROR
fi
else
if ! mv "${FULLPATH}" "${FULLPATH}"_bak; then
reason="can't create file backup"
error=true
ERROR
fi
fi
if ! [ "${PROGNAME}" = "phpMyAdmin" ]; then
if ! mysqldump --lock-tables -u "${DBUSER}" -p"${DBPASSWORD}" "${DBNAME}" >"${FULLPATH}"_bak/database_"${DATE}".sql >/dev/null 2>&1; then
reason="can't create mysql backup"
error=true
ERROR
fi
fi
if [ ${error} = false ]; then
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${title}"
fi
else
reason="can't deleting old file backup"
ERROR
fi
else
reason="can't find ${FULLPATH}, please check WEBPATH and WEBFOLDER in config file"
ERROR
fi