Added some conditions for do a backup of directory.