backup.sh: Clean up junk if tar creation fails
authorMegaBrutal <code+git@megabrutal.com>
Thu, 20 Aug 2015 05:31:48 +0000 (07:31 +0200)
committerMegaBrutal <code+git@megabrutal.com>
Thu, 20 Aug 2015 05:31:48 +0000 (07:31 +0200)
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

mysql/backup.sh

index a68853f..5040f3f 100755 (executable)
@@ -49,5 +49,8 @@ then
        done
 else
        echo "Failed to create archive: ${tarname}."
+       echo "Cleaning up..."
+       cd ${stordir}
+       rm -rv ${tempdir}
        exit 1
 fi