feat: fail backup on script errors

This commit is contained in:
mandlm 2022-10-09 14:42:33 +02:00
parent a02735d982
commit ede6cd537e
Signed by: mandlm
GPG Key ID: 4AA25D647AA54CC7
4 changed files with 8 additions and 8 deletions

View File

@ -11,7 +11,7 @@ lftp -u "$FTP_USER","$FTP_PASSWORD" $FTP_HOST <<EOF
set ssl:verify-certificate no
mirror --delete --parallel=4 --use-pget-n=10 $REMOTE_DIR $LOCAL_DIR;
exit
EOF
EOF || exit 1
echo
echo "Transfer finished"
date

View File

@ -4,7 +4,7 @@ BACKUP_DIR="/backup/database"
echo "Starting to backup mysql database"
mkdir --parents $BACKUP_DIR
mysqldump --single-transaction --host=$MYSQL_BACKUP_HOST --user=$MYSQL_BACKUP_USER --password=$MYSQL_BACKUP_PASSWORD $MYSQL_BACKUP_DATABASE > $BACKUP_DIR/$MYSQL_BACKUP_DATABASE.sqldump
mkdir --parents $BACKUP_DIR || exit 1
mysqldump --single-transaction --host=$MYSQL_BACKUP_HOST --user=$MYSQL_BACKUP_USER --password=$MYSQL_BACKUP_PASSWORD $MYSQL_BACKUP_DATABASE > $BACKUP_DIR/$MYSQL_BACKUP_DATABASE.sqldump || exit 1
echo "Mysql database backup finished"

View File

@ -4,7 +4,7 @@ BACKUP_DIR="/backup/database"
echo "Starting to backup postgres database"
mkdir --parents $BACKUP_DIR
PGPASSWORD=$PG_PASSWORD pg_dump --host=$PG_HOST --username=$PG_USER $PG_DATABASE > $BACKUP_DIR/$PG_DATABASE.sqldump
mkdir --parents $BACKUP_DIR || exit 1
PGPASSWORD=$PG_PASSWORD pg_dump --host=$PG_HOST --username=$PG_USER $PG_DATABASE > $BACKUP_DIR/$PG_DATABASE.sqldump || exit 1
echo "Postgres database backup finished"

View File

@ -1,13 +1,13 @@
#!/usr/bin/env sh
if [[ -n "$DO_FTP_BACKUP" ]]; then
sh /usr/local/etc/urbackup/ftp_backup.sh
sh /usr/local/etc/urbackup/ftp_backup.sh || exit 1
fi
if [[ -n "$DO_MYSQL_BACKUP" ]]; then
sh /usr/local/etc/urbackup/mysql_backup.sh
sh /usr/local/etc/urbackup/mysql_backup.sh || exit 1
fi
if [[ -n "$DO_POSTGRES_BACKUP" ]]; then
sh /usr/local/etc/urbackup/postgres_backup.sh
sh /usr/local/etc/urbackup/postgres_backup.sh || exit 1
fi