Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase number of stored copies #8

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

KonstantinKondratenko
Copy link
Collaborator

No description provided.

@KonstantinKondratenko
Copy link
Collaborator Author

Использовать вот так:

  1. нужно разместить на уровне, где лежат каталоги
  2. ./keep_n_backups_for_templates.sh N folder1 [folder2 ... folderN]
    Тут N - количество копий
    требуется как минимум 1 папка, иначе скрипт ломается

скрипт копирует в ../backups папки и называет их <имя>_месяц_день_час_минуты
Потом если папок (которые начинаются на <имя>) больше, чем N, то удаляет количество - N

keep_n_backups_for_templates.sh Show resolved Hide resolved
keep_n_backups_for_templates.sh Show resolved Hide resolved
keep_n_backups_for_templates.sh Show resolved Hide resolved
fi

if [ "$#" -lt 2 ]; then
echo "Usage: $0 N folder1 [folder2 ... folderN]"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поясните, как интерпретируются аргументы folderN

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

пока реализовано так:
передаем N - число хранимых копий
а потом как минимум 1 папку, но можно и больше папок, которые копируем, то есть для 1 курса пми по проге будет выгляжеть так:
./keep_n_backups_for_templates.sh 5 pr-2024-4381 pr-2024-4382 pr-2024-4383 pr-2024-4384 pr-2024-4385 pr-2024-4388

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да, у меня не очень удачное описание, тут N количество и folderN никак не свзяаны в них N

echo "Folder $folder copied into $BACKUP_DIR/$new_folder_name"
}

for folder in "${FOLDERS[@]}"; do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

По задумке folder1 [folder2 ... folderN] это подстроки от начала имен папок.
Например, у нас могут быть папки вида:
pr-2023-1, pr-2024-5, cs-2025-6

Мы передаем в качестве аргументов:
pr-2023- и cs-2025-

соответственно, должны быть обработаны только каталоги, которые начинаются с одной из этих подстрок.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

хм, понял, пока работает так, что нужно прописать полные название копируемых папок (pr-2023-3381 pr-2023-3382 и тд)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

добавил prefix
теперь запускать нужно так:
./new.sh 5 pr-2024

Вот как будет выглядеть вывод:

Start copy pr-2024-4388 into ../backups/pr-2024-4388_2024_11_20_16_53
Folder pr-2024-4388 copied into ../backups/pr-2024-4388_2024_11_20_16_53
Start copy pr-2024-4382 into ../backups/pr-2024-4382_2024_11_20_16_53
Folder pr-2024-4382 copied into ../backups/pr-2024-4382_2024_11_20_16_53
Start copy pr-2024-4381 into ../backups/pr-2024-4381_2024_11_20_16_53
Folder pr-2024-4381 copied into ../backups/pr-2024-4381_2024_11_20_16_53
Start copy pr-2024-4383 into ../backups/pr-2024-4383_2024_11_20_16_53
Folder pr-2024-4383 copied into ../backups/pr-2024-4383_2024_11_20_16_53
Start copy pr-2024-4384 into ../backups/pr-2024-4384_2024_11_20_16_53
Folder pr-2024-4384 copied into ../backups/pr-2024-4384_2024_11_20_16_53
Start copy pr-2024-4385 into ../backups/pr-2024-4385_2024_11_20_16_53
Folder pr-2024-4385 copied into ../backups/pr-2024-4385_2024_11_20_16_53
Started deleting ../backups/pr-2024-4388_2024_11_20_16_44
Deleted old copy ../backups/pr-2024-4388_2024_11_20_16_44
Started deleting ../backups/pr-2024-4382_2024_11_20_16_44
Deleted old copy ../backups/pr-2024-4382_2024_11_20_16_44
Started deleting ../backups/pr-2024-4381_2024_11_20_16_44
Deleted old copy ../backups/pr-2024-4381_2024_11_20_16_44
Started deleting ../backups/pr-2024-4383_2024_11_20_16_44
Deleted old copy ../backups/pr-2024-4383_2024_11_20_16_44
Started deleting ../backups/pr-2024-4384_2024_11_20_16_44
Deleted old copy ../backups/pr-2024-4384_2024_11_20_16_44
Started deleting ../backups/pr-2024-4385_2024_11_20_16_44
Deleted old copy ../backups/pr-2024-4385_2024_11_20_16_44

Copy link
Collaborator

@HadronCollider HadronCollider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В целом, ок - добавил в джобу бакапов

до 02.12 смотрим - потом мержим

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Увеличить количество хранимых копий
3 participants