Skip to content

Commit

Permalink
Add sleep option
Browse files Browse the repository at this point in the history
  • Loading branch information
lloesche committed Jul 17, 2024
1 parent cc17678 commit 5764598
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
16 changes: 15 additions & 1 deletion fixbackup/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import os
import time
from pathlib import Path
from typing import List
from .logger import add_args as logging_add_args, log
Expand All @@ -12,11 +13,24 @@
def main() -> None:
args = parse_args([logging_add_args, s3_add_args, *backup_add_args])
exit_code = 0
log.info("Starting FIX Databases Backup System")
log.info("Starting Fix Databases Backup System")

if not verify_binaries():
sys.exit(1)

if args.sleep:
# This option is used to keep the container running for debugging purposes.
# It allows you to connect to it inside of e.g. a K8s environment
# and manually test the backup process. Alternatively, you could
# override the entrypoint of the container and sleep indefinitely.
log.info("Sleeping forever")
try:
while True:
time.sleep(300)
finally:
log.info("Shutdown complete")
sys.exit(0)

backup_directory = Path(args.backup_directory)
rmdir_backup_directory = True
if backup_directory.exists() and not backup_directory.is_dir():
Expand Down
7 changes: 7 additions & 0 deletions fixbackup/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ def parse_args(add_args: List[Callable[[ArgumentParser], None]]) -> Namespace:
help="Name of the environment",
default=os.getenv("FIX_ENVIRONMENT", "dev"),
)
arg_parser.add_argument(
"--sleep",
help="Don't do anything, just sleep forever",
dest="sleep",
action="store_true",
default=False,
)

for add_arg in add_args:
add_arg(arg_parser)
Expand Down
2 changes: 1 addition & 1 deletion fixbackup/backup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .arangodb import backup as arangodb_backup, add_args as arangodb_add_args
from ..utils import valid_hostname, valid_ip, valid_dbname

add_args = [redis_add_args, mysql_add_args, arangodb_add_args, postgresql_add_args]
add_args = [redis_add_args, mysql_add_args, postgresql_add_args, arangodb_add_args]


def backup(args: Namespace, backup_directory: Path) -> Tuple[List[Path], bool]:
Expand Down

0 comments on commit 5764598

Please sign in to comment.