|
@ -9,8 +9,9 @@ local commandaction="Backup" |
|
|
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" |
|
|
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" |
|
|
|
|
|
|
|
|
check.sh |
|
|
check.sh |
|
|
|
|
|
backuplock= |
|
|
# Check if a backup is pending or has been aborted using .backup.lock |
|
|
# Check if a backup is pending or has been aborted using .backup.lock |
|
|
if [ -f "${tmdpdir}/.backup.lock" ]; then |
|
|
if [ -f "${tmpdir}/.backup.lock" ]; then |
|
|
fn_print_warning_nl "A backup is currently pending or has been aborted." |
|
|
fn_print_warning_nl "A backup is currently pending or has been aborted." |
|
|
while true; do |
|
|
while true; do |
|
|
read -e -i "y" -p "Continue anyway? [Y/N]" yn |
|
|
read -e -i "y" -p "Continue anyway? [Y/N]" yn |
|
@ -29,7 +30,6 @@ backupname="${servicename}-$(date '+%Y-%m-%d-%H%M%S')" |
|
|
# Tells how much will be compressed using rootdirduexbackup value from info_distro |
|
|
# Tells how much will be compressed using rootdirduexbackup value from info_distro |
|
|
fn_print_info_nl "A total of ${rootdirduexbackup} will be compressed into the following backup:" |
|
|
fn_print_info_nl "A total of ${rootdirduexbackup} will be compressed into the following backup:" |
|
|
echo "${backupdir}/${backupname}.tar.gz" |
|
|
echo "${backupdir}/${backupname}.tar.gz" |
|
|
echo "" |
|
|
|
|
|
while true; do |
|
|
while true; do |
|
|
read -e -i "y" -p "Continue? [Y/N]" yn |
|
|
read -e -i "y" -p "Continue? [Y/N]" yn |
|
|
case $yn in |
|
|
case $yn in |
|
@ -38,7 +38,6 @@ while true; do |
|
|
* ) echo "Please answer yes or no.";; |
|
|
* ) echo "Please answer yes or no.";; |
|
|
esac |
|
|
esac |
|
|
done |
|
|
done |
|
|
echo "" |
|
|
|
|
|
check_status.sh |
|
|
check_status.sh |
|
|
if [ "${status}" != "0" ]; then |
|
|
if [ "${status}" != "0" ]; then |
|
|
echo "" |
|
|
echo "" |
|
@ -61,11 +60,11 @@ if [ ! -d "${backupdir}" ]; then |
|
|
mkdir "${backupdir}" |
|
|
mkdir "${backupdir}" |
|
|
fi |
|
|
fi |
|
|
# Create lockfile |
|
|
# Create lockfile |
|
|
touch "${tmdpdir}/.backup.lock" |
|
|
touch "${tmpdir}/.backup.lock" |
|
|
# Compressing files |
|
|
# Compressing files |
|
|
tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "backups" ./* |
|
|
tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "backups" ./* |
|
|
# Remove lockfile |
|
|
# Remove lockfile |
|
|
rm "${tmdpdir}/.backup.lock" |
|
|
rm "${tmpdir}/.backup.lock" |
|
|
# Check tar exit code and act accordingly |
|
|
# Check tar exit code and act accordingly |
|
|
if [ $? == 0 ]; then |
|
|
if [ $? == 0 ]; then |
|
|
fn_print_ok_nl "Backup created: ${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size" |
|
|
fn_print_ok_nl "Backup created: ${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size" |
|
@ -101,6 +100,5 @@ else |
|
|
fn_print_error_nl "Backup failed: ${backupname}.tar.gz" |
|
|
fn_print_error_nl "Backup failed: ${backupname}.tar.gz" |
|
|
fn_script_log_error "Backup failed: ${backupname}.tar.gz" |
|
|
fn_script_log_error "Backup failed: ${backupname}.tar.gz" |
|
|
fi |
|
|
fi |
|
|
sleep 1 |
|
|
sleep 0.5 |
|
|
echo "" |
|
|
|
|
|
core_exit.sh |
|
|
core_exit.sh |
|
|