diff --git a/DIRECTORY_TREE.md b/DIRECTORY_TREE.md index 5c058a8..4f91d0b 100644 --- a/DIRECTORY_TREE.md +++ b/DIRECTORY_TREE.md @@ -9,6 +9,7 @@ │ ├─ README.en.md │ ├─ README.md │ ├─ archive_backup.sh +│ ├─ archive_cleanup.sh │ ├─ archive_packages.sh │ ├─ info_param.sh │ ├─ info_references.sh diff --git a/bash_scripts/README.en.md b/bash_scripts/README.en.md index 9a9af2f..0ae7a86 100644 --- a/bash_scripts/README.en.md +++ b/bash_scripts/README.en.md @@ -5,6 +5,7 @@ Creating an archive, switching the domain, composing scripts and creating reposi | № | Bash scripts | Actions performed | |---|:-----------------------------------------------|:--------------------------------------------------------------------------------------------| | 1 | [**archive_backup.sh**](archive_backup.sh) | Creating a common archive for the directories of projects on the current date. | +| | [archive_cleanup.sh](archive_cleanup.sh) | Deleting files and folders from the directories of projects before restoring the archive. | | | [archive_packages.sh](archive_packages.sh) | Building websites, creating and copying archives for deployment. | | 2 | [**info_param.sh**](info_param.sh) | Parameter for other scripts. Switching the domain of the remote repository. | | | [info_references.sh](info_references.sh) | Updating the domain of a remote repository in cross-references in descriptions. | diff --git a/bash_scripts/README.md b/bash_scripts/README.md index 8d3a3a4..c23a012 100644 --- a/bash_scripts/README.md +++ b/bash_scripts/README.md @@ -5,6 +5,7 @@ | № | Скрипты Bash | Выполняемые действия | |---|:-----------------------------------------------|:---------------------------------------------------------------------------------| | 1 | [**archive_backup.sh**](archive_backup.sh) | Создание общего архива для каталогов проектов на текущую дату. | +| | [archive_cleanup.sh](archive_cleanup.sh) | Удаление файлов и папок из каталогов проектов перед восстановлением архива. | | | [archive_packages.sh](archive_packages.sh) | Сборка вёб-сайтов, создание и копирование архивов для развёртывания. | | 2 | [**info_param.sh**](info_param.sh) | Параметр для других скриптов. Переключение домена удалённого репозитория. | | | [info_references.sh](info_references.sh) | Обновление домена удалённого репозитория в перекрёстных ссылках в описаниях. | diff --git a/bash_scripts/archive_cleanup.sh b/bash_scripts/archive_cleanup.sh new file mode 100755 index 0000000..0e45494 --- /dev/null +++ b/bash_scripts/archive_cleanup.sh @@ -0,0 +1,12 @@ +#!/bin/bash +echo "Удаление файлов и папок из каталогов проектов перед восстановлением архива." +echo "Отмена" && exit 0; # предохранитель +cd .. +# обходим все репозитории, расположенные на одном уровне с текущим +find .. -mindepth 1 -maxdepth 1 -type d | sort -r | while read -r dir; do + echo "Обработка: $dir" + # заходим в каталог, иначе пропускаем итерацию + cd "$dir" || continue + # удаляем вложенные файлы и папки кроме папок '.git' и '.idea' + find . -mindepth 1 -maxdepth 1 -type f,d -not -name '.git' -not -name '.idea' -print0 | xargs -0 rm -r +done