From: MegaBrutal Date: Thu, 20 Aug 2015 05:31:48 +0000 (+0200) Subject: backup.sh: Clean up junk if tar creation fails X-Git-Url: http://git.megabrutal.com/?p=mgsautils.git;a=commitdiff_plain;h=9ec1d5004911a56e6853d3bff2ac5306013dfbc5;hp=0ff0a58157fc0acd3e9ab407ce8be25bcea01a97 backup.sh: Clean up junk if tar creation fails If the file system gets full during tar creation, and the junk files (SQL dumps, partial TAR) stay there, the file system is left with 100% usage. This may have very unpleasant consequences, so it's best to simply remove those files. modified: mysql/backup.sh --- diff --git a/mysql/backup.sh b/mysql/backup.sh index a68853f..5040f3f 100755 --- a/mysql/backup.sh +++ b/mysql/backup.sh @@ -49,5 +49,8 @@ then done else echo "Failed to create archive: ${tarname}." + echo "Cleaning up..." + cd ${stordir} + rm -rv ${tempdir} exit 1 fi