print "Archiving backup to '" + archive_path + "'..." if archive_type == 'gz' or archive_type == 'bz2': try: import tarfile tar = tarfile.open(archive_path, 'w:' + archive_type) tar.add(backup_subdir, os.path.basename(backup_subdir)) tar.close() except ImportError, e: err_msg = "Import failed: " + str(e) err_code = -2 except tarfile.TarError, e: err_msg = "Tar failed: " + str(e) err_code = -3