diff --git a/b2-retention.sh b/b2-retention.sh index 85f346a..c930b61 100755 --- a/b2-retention.sh +++ b/b2-retention.sh @@ -1,7 +1,7 @@ #!/usr/bin/env sh FILE_QUOTA=${FILE_QUOTA:-7} -FILE_QUOTA=$(("$FILE_QUOTA" + 1)) +FILE_QUOTA=$((FILE_QUOTA + 1)) TO_DELETE=$( b2v4 ls b2://"$BUCKET_NAME" | tac | tail -n +"$FILE_QUOTA" | tr '\n' ' ' ) PIDS="" diff --git a/local-retention.sh b/local-retention.sh index 7453bfb..1db6c72 100755 --- a/local-retention.sh +++ b/local-retention.sh @@ -7,17 +7,17 @@ list_after_n() { ARCHIVE_DIR=${ARCHIVE_DIR:-"/archive"} FILE_QUOTA=${FILE_QUOTA:-7} -old_archives=$( find "$ARCHIVE_DIR" -maxdepth 1 -type f -printf "%f\n" ) -old_dirs=$( find "$ARCHIVE_DIR" -maxdepth 1 -mindepth 1 -type d -printf "%f\n" ) +old_archives=$( find "$ARCHIVE_DIR" -maxdepth 1 -type f -print ) +old_dirs=$( find "$ARCHIVE_DIR" -maxdepth 1 -mindepth 1 -type d -print ) last_n_archives=$( list_after_n "$old_archives" "$FILE_QUOTA" ) last_n_dirs=$( list_after_n "$old_dirs" "$FILE_QUOTA" ) for archive in $last_n_archives; do - rm "$ARCHIVE_DIR/$archive" + rm "$archive" done for dir in $last_n_dirs; do - rm -r "$ARCHIVE_DIR/$dir" + rm -r "$dir" done