/
githubmirror
/
gogs
Обзор
Документация
Войти
/
githubmirror
/
gogs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docker/runtime/backup-rotator.sh
28 строк
739 B
Atin
chore: fix typos in code comments (#6556)
19 май 2021, 08:12
Не верифицирован
19 май 2021, 08:12
d6987ee
Код
Авторство
О чём код?
#!/usr/bin/env sh # This is very simple, yet effective backup rotation script. # Using find command, all files that are older than BACKUP_RETENTION_DAYS are accumulated and deleted using rm. main() { BACKUP_PATH="${1:-}" FIND_EXPRESSION="${2:-mtime +7}" if [ -z "${BACKUP_PATH}" ]; then echo "Error: Required argument missing BACKUP_PATH" 1>&2 exit 1 fi if [ "$(realpath "${BACKUP_PATH}")" = "/" ]; then echo "Error: Dangerous BACKUP_PATH: /" 1>&2 exit 1 fi if [ ! -d "${BACKUP_PATH}" ]; then echo "Error: BACKUP_PATH doesn't exist or is not a directory" 1>&2 exit 1 fi # shellcheck disable=SC2086 find "${BACKUP_PATH}/" -type f -name "gogs-backup-*.zip" -${FIND_EXPRESSION} -print -exec rm "{}" + } main "$@"