Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
agoncharov-reef committed Feb 24, 2025
1 parent 4820803 commit ba8efc1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -eu

if [ ! -f "$1" ]; then
echo "Pass existing backup file name as the first argument"
find ${BACKUP_LOCAL_DIR} -name "*.dump.zstd" | sort -r
find "$BACKUP_LOCAL_DIR" -name "*.dump.zstd" | sort -r
exit 127
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${SCRIPT_DIR}/common.sh"

echo "Local backups:"
find ${BACKUP_LOCAL_DIR} -name "*.dump.zstd" | sort -r
find "$BACKUP_LOCAL_DIR" -name "*.dump.zstd" | sort -r

if [ -n "${BACKUP_B2_BUCKET}" ]; then
export B2_APPLICATION_KEY_ID="$BACKUP_B2_KEY_ID"
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.repostory_name}}/backups/bin/restore-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source "${SCRIPT_DIR}/common.sh"

if [[ $# -ne 1 ]]; then
echo "Usage: ./restore-db.sh <FILE>"
${SCRIPT_DIR}/list-backups.sh
"${SCRIPT_DIR}"/list-backups.sh
exit 2
fi

Expand All @@ -14,7 +14,7 @@ if [[ "$1" == b2://* || "$1" == b2id://* ]]; then
export B2_APPLICATION_KEY="$BACKUP_B2_KEY_SECRET"
b2 cat "$1" | pg_restore -c -d "$DATABASE_URL"
else
cat "$1" | pg_restore -c -d "$DATABASE_URL"
pg_restore -c -d "$DATABASE_URL" < "$1"
fi

echo 'restore finished'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
if [ -n "${BACKUP_LOCAL_ROTATE_KEEP_LAST:-}" ]; then
echo "Rotating backup files - keeping ${BACKUP_LOCAL_ROTATE_KEEP_LAST} last ones"
files_to_delete=$(ls -1 /var/backups/*.dump.zstd | sort -r | tail -n "+${BACKUP_LOCAL_ROTATE_KEEP_LAST}")
files_to_delete=$(find /var/backups -name "*.dump.zstd" | sort -r | tail -n "+${BACKUP_LOCAL_ROTATE_KEEP_LAST}")
echo "$files_to_delete" | xargs rm
echo "Removed:"
echo "$files_to_delete"
Expand Down
14 changes: 7 additions & 7 deletions {{cookiecutter.repostory_name}}/backups/bin/serve_metrics.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import logging
import subprocess
import time
from argparse import ArgumentParser
from collections.abc import Iterator
from dataclasses import dataclass, field
from datetime import datetime, timedelta, UTC
import logging
from datetime import UTC, datetime, timedelta
from os import environ
from pathlib import Path
from tempfile import NamedTemporaryFile
from collections.abc import Iterator
import subprocess
import time

import structlog
from b2sdk.v2 import B2Api, InMemoryAccountInfo
from prometheus_client import Gauge, Histogram, start_http_server
from structlog.contextvars import bound_contextvars
from b2sdk.v2 import InMemoryAccountInfo, B2Api
from prometheus_client import Histogram, start_http_server, Gauge

MiB = 1
GiB = 1024 * MiB
Expand Down

0 comments on commit ba8efc1

Please sign in to comment.